Write a program that will ask the user for the name of an item, the part number of the item, the cost of the item and the quantity of the item. The program will then calculate the total cost of the item. The program will also keep track of the running total for an undetermined amount of items (Hint: Sentinel Loop).
The name of the item, part number of the item, cost of the item, quantity of the item, total cost of the item will be output to a file (Invoice.txt). The running total of all items will be output to the bottom of the file.
Example output file:
Name of Item Part Number of Item Cost of Item Quantity Total Cost
Hammer 12-34-A $12.00 2 $24.00
Candy Bar 8A87 $0.75 3 $1.50
Total Cost: $25.50

Recommended Answers

All 6 Replies

I can help out, but where are you stuck? Im assuming this is a homework assignment. You will find your later classes will be a lot more difficult if you dont do this on your own.
What have you got down as far as pseudo-code or a flow-chart ? Have you broken this down into small chunks to work on?

What you will need is pretty basic, a post-test repetition statement such as a do-while loop that will test after the first inputs are entered, a sentinel value (such as -1 to end the loop if that value is entered), an output file stream to send you formatted data, etc. Build a basic skeleton and we'll go from there.

Yeah I really just need help figuring out how to set up that kind of loop and sentinel in this situation.

Or if you could help me write a pseudo code, I should be able to make the program

Ok, what do you have so far?

Are you doing this as an assignment? Maybe you should read the assigned chapter first.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.