using text file

Hello. I am taking my first computer class and my teacher doesn't offer any type of guidance. She expects us to already know what to do. So I need help writing a program that does the following:

Calculate the amount a customer should be charged at a gas station.Each customer is identified by his first name. This name should appear on the bill. Fees for the car wash are $4.25 with gasoline purchase of $35.00 or more and $10.00 otherwise. Three kinds of gasoline are available: regular at 3.39, unleaded at 3.55 and premium at 3.65 per gallon. Input consists of the customer name, number of gallons purchased, kind of gasoline purchased (R, U, P, or, for no purchase, N), and car wash desired (Y or N). Read data from a text file named customers.txt.

What I am confused about is what is the first thing I am supposed to do, besides defining variables and creating the text file using the information she has given us. Any help is greatly appreciated.
Let me make sure I'm understanding you correctly... you don't have any programming experience? Or you don't know how to do the specific things she's asking? Or you just don't know how to start?

If the first one is true, then you better get cracking. But honestly, if you have no programming exposure, and this is a timed assignment, you're probably not going to be able to do it. I would seek help from the instructor.

If it's the second one, here are a few short tutorials on the things you mentioned.

Basic IO: http://www.cplusplus.com/doc/tutorial/basic_io/
File IO: http://www.cplusplus.com/doc/tutorial/files/

If you just don't know how to start, here are a few things you can consider.

1. You're going to need a way to store all the information on this customers. You could use a simple struct and have an array or vector of struct variables.
2. You're going to need to read in the information. Did she provide you with a sample text file to look at? If so, consider how the file is formatted. What do you need to do to read that information in? How can you use a loop to read in multiple customer records and then store them in your struct variables?
3. The rest is just simple variable arithmetic and outputting it in the way she has asked you to.

If you can provide more information as to what exactly you're having trouble with, I can help you better.
Topic archived. No new replies allowed.