Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A hardware store charges 4 cents for nust and 6 cents for bolts. Write a c++ pro

ID: 3537315 • Letter: A

Question

A hardware store charges 4 cents for nust and 6 cents for bolts. Write a c++ program that asks the user for the number of bolts and number of nuts in their purchase and then calculates and prints out the total cost.


As an added feature, the program should check the order. It is usally a mistake if there are more bolts than nuts. (but it is ok if there are more nuts than bolts). So if there are more bolts than nuts, the program should display the message "Check the Order!" Otherwise, the program should instead display "Order is OK."


In either case, the total cost is written out.


Explanation / Answer

#include<iostream.h>

int main()

{

int bolt,nut;

cout<<"enter number of bolts";

cin>>bolt;

cout<<"enter number of nuts";

cin>>nut;

if(bolt>nut)

cout<<"check the order!";

else

cout<<"order is ok";

int total=4*nut+6*bolt;

cout<<total;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote