Purchase Solution

Miracle C program on a Grocery Shop

Not what you're looking for?

Ask Custom Question

I need to modify the existing code (separate attachment) to be more orderly in its output appearance. Basically so that the displays are similar to what is below in the samples.
Right now, I get this error when attempting to compile in Miracle C:
c:program filesmiracle cnewweek4.c: line 18: wrong # args in function call
'{ printf("Enter name for product %d: ",i+1)'
aborting compile
If I add in #include <stdio.h> at the beginning, the program runs, but when it comes to the point where customer pick their products the display is very is disorganized and looks like this:
Products: n1. grapes:n2. corn:n3. oranges:n4. potatoes:n5. beans:nnSelect a product or 0 to complete
And once selecting 0 to complete checkout, it looks like this:
checkoutn0
Purchase Total: 0.00nDiscount Total: 0.00nTotal Amount Due: 0.00nnThank you for shopping!nnC for che
ckout or X for exit:
I would to have it look like the samples below instead of strung out if possible and is there a way to get the "n" out of the display?
1) Include comments within the program to document the program internally.
2) Verify the program compiles and runs.
3) Thank you very much for your help.
Sample Inputs (customer inputs in red):
Enter name for product 1: grapes
Enter name for product 2: corn
Enter name for product 3: potatoes
Enter name for product 4: asparagus
Enter name for product 1: oranges

Enter per-pound price for Asparagus: $ 0.79
Enter per-pound price for Oranges: $ 1.29
Enter per-pound price for Potatoes: $ 4.99
Enter per-pound price for Corn: $ 1.09
Enter per-pound price for Grapes: $ 1.59

C for Checkout, X to exit: C

Products:
1. Asparagus
2. Oranges
3. Potatoes
4. Corn
5. Grapes

Select a product or 0 to complete checkout: 1

Enter the weight: 10

Products:
1. Asparagus
2. Oranges
3. Potatoes
4. Corn
5. Grapes

Select a product or 0 to complete checkout: 2

Enter the weight: 5.5

Products:
1. Asparagus
2. Oranges
3. Potatoes
4. Corn
5. Grapes

Select a product or 0 to complete checkout: 5

Enter the weight: 2.3

Products:
1. Asparagus
2. Oranges
3. Potatoes
4. Corn
5. Grapes

Select a product or 0 to complete checkout: 3

Enter the weight: 7

Products:
1. Asparagus
2. Oranges
3. Potatoes
4. Corn
5. Grapes

Select a product or 0 to complete checkout: 0

Purchase Total: $ 53.58
Discount Total: $ 2.68
Total Amount due: $ 50.90

C for Checkout, X to exit: X

Thank you for shopping with us!

Purchase this Solution

Solution Summary

The program that was tested in Miracle C and it compiles and runs fine. The code has been further commented to explain the scanf(). The "n"s are in fact "n" or new line characters in C. The "" backslashes are somehow missing from the whole program probably due to an incorrect input filtering in Brainmass web server.
Please look into the attached compressed file, which should survive any character translation done by the system.

Attached are all the files created by Miracle C. However, you only need the grocery.c file to compile and test.

Solution Preview

The program that was tested in Miracle C and it compiles and runs fine. The code has been further commented to explain the scanf(). The ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Javscript Basics

Quiz on basics of javascript programming language.

C++ Operators

This quiz tests a student's knowledge about C++ operators.