954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help With Looping Program

I need desperately help with this homework assignment. And I'm starting from the beginning. It's a problem that makes us write a counting loop program, and I believe you use while and if else in this program. Here is the problem and the given outputs. I got started on it, but then my teacher lost me with declaring the variables for this problem (which is pretty much the beginning). Thank you to all who help even just a little or just getting me started!

Create a C++ program that processes a data file created from cash registers at the local lemonade stand. The lemonade stand sells three sizes of lemonade: small, medium, and large. The small drink has an item number of 1 and sells for $0.50, the medium drink an item number of 2 and sells for $1.00, and the large drink an item number of 3 and sells for $1.50. Children under 10 get a 10% discount. The data file that gets created by the cash register at the end of the day tells how many total glasses of lemonade were sold followed by a list of 1's, 2's, and 3's with A or C after each number to indicate a child or adult sale.

Sample Data File
5 2 A 1 C 3 C 1 A 2 C
This indicates that 5 glasses were sold, 2 small, 2 medium, and 1 large.

Sample Output
5 Glasses Sold - 2 small, 2 medium, and 1 large
Small - 1 child, 1 adult for a total of $0.95
Medium - 0 child, 2 adult for a total of $2.00
Large - 1 child, 0 adult for a total of $1.35
Total receipts from children $1.80
Total receipts from adults $2.50
Total receipts $4.30

Program Requirements
The program must pause after outputting the receipt.

andrea_kay
Newbie Poster
1 post since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

You need to make and effort, work on this and post some code before we can help you out.

If you aren't even familiar with variable declarations, I don't understand why your teacher is making you do file I/O, and something which is not a basic loop.

Here is a basic tutorial to help you get started.

stilllearning
Posting Whiz
309 posts since Oct 2007
Reputation Points: 161
Solved Threads: 43
 

This input file makes no sense based on what you described.

I see the "5" at the beginning, then "2 A" - for 2 Adults? - then "1 C" - for 1 Child? - then "3 C" - for 3 Children? - we're already over five total. Nowhere do I see any indication of small, medium, or large. You must be leaving something out.

I need desperately help ... The data file that gets created by the cash register at the end of the day tells how many total glasses of lemonade were sold followed by a list of 1's, 2's, and 3's with A or C after each number to indicate a child or adult sale.

Sample Data File 5 2 A 1 C 3 C 1 A 2 C This indicates that 5 glasses were sold, 2 small, 2 medium, and 1 large. ...

DevonMcC++
Newbie Poster
16 posts since Feb 2008
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You