scanf

On online retailer has hired you to write a program to calculate the total cost of a customer's purchases. The customer may order books, movies, and peanuts. Books are $9 each. Movies are $13.99 each. Peanuts are sold at $1.80 per pound and can be purchased by the tenth of a pound. The shipping cost for each book is $1.06. The shipping cost for movies is 5% of the movie subtotal portion of the order. The shipping charge for peanuts is 50 cents per pound of peanuts ordered.

The program must use a loop to present the customer with the following exact menu allowing him to make one or more orders for each of the three products if he desires.

1 Books
2 Movies
3 Peanuts
4 Checkout


The program must prompt the user to input the number of books, movies, and peanuts (in lbs.) that he would like to purchase and obtain those amounts in that specified order. The program must then output the total cost of the three orders rounded to the nearest whole dollar.

The customer is allowed to make two or more separate orders for the same product. For example, the customer may order 3 books and 2 movies but no peanuts. Or, the customer could order 5 books, 1 pound of peanuts, and 3 movies in that order. Or, the customer could order 6 books, 3 movies, and then 2 more books. The customer may choose menu option #4 to exit the program at any time, even if he has made no purchase. The final price must be a value rounded to the nearest penny. Also, display the message "Invalid input." if the user inputs a quantity that is less than 0 or greater than 50 and immediately display the menu again. Also, if the user inputs a menu choice below 1 or greater than 4, display the message "Invalid input." and immediately display the menu again. If the user inputs text where a numeric input is requested, display the message "Invalid input." as well and display the menu again.

This program must compile and execute as a C program rathr than a C++ program. Specifically, the file extension of the source file must be .c instead of .cpp and it cannot make use of iostream, cin, cout, <<, >>, endl or any other non-C keywords or syntax.

Preconditions:

  • none

You must hand in the following on separate pages stapled in this specified order:

  1. The hardcopy source code for this assignment.Staple multiple pages together, if applicable.
  2. The output of the program (black text on white background) with the inputs 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 1, 60, 6, 4 which should result in the cost $54.10