Friday, July 25th 2008, 2:53am UTC+1

You are not logged in.

  • Login
  • Register

haelly

Beginner

Posts: 4

Location: LONDON

Occupation: STUDENT

1

Friday, December 28th 2007, 4:38pm

[cpp] help with c++

Read input from a data file rather than from the keyboard , add the account number and the customer name and phone to the set of data for each water bill.
Create a structure type invoice with the field for customer name(a character array of length 15), phone (a character array of length 13 to accommodate a three-digit area code , a dash, a three-digit exchange , another dash, and a four-digit number),account number (long) ,volume in gallons(double),and bill amount (double),and bill amount (double). Instead of parallel arrays for separate elements of the bill, use an array of Invoice structures bills[].
Create an input file using a ext editor .use an object of the library type fstream to open the file in the ios::in mode. Define the file name as a constant character array FIN[] , supply either a full fie name , e.g., “c\data\invoices.dat” , or default directory file name , e.g. , “invoices.dat”; to be able to use the default directory that your compiler uses as the default directory. After defining a file object , test whether the operation failed ; print a message and terminate the program if the file cannot be opened.
In the data file, place the data for each water bill on a separate line .Allocate enugh space for the customer name and phone number , e.g. 16 character and 14 characters , at the beginning of the line .Format account number and volume in columns. Here is an example of a short input file:

Smith 617-353-2566 101808 200
Brown 508-790-9313 102313 300
Black 212-517-6770 10541 400

In the infinite input loop, use get() to read up to 15 characters into a local character array name[]; break the loop I the operation raises the end of file indicator. Use operator >> to read data into local variables ‘phone’ , ‘account’ , and ‘gallons’. Use get() again to through away the new line character at the end of the line (|to avoid confusing get() when it is called again).Break the input loop when there is no more space in the array of invoice objects invoices[].
If the input is valid and the array space is available compute the amount of the bill , copy the character arrays, (use strcpy()) and numeric data into the appropriate element of the array invoices[].
Modify program output to accommodate additional data e.g.,

Name Phone Account Volume Amount
Smith 617-353-2566 101808 200.00 22.00
Brown 508-790-9313 102313 300.00 27.00
Black 212-517-6770 105411 400.00 32.00
Total
haelly has attached the following files:
  • c5.jpg (223.47 kB - 389 times downloaded - Last download: Jul 11th 2008, 12:34am)
  • c51.jpg (236.61 kB - 349 times downloaded - Last download: Jul 11th 2008, 12:35am)
  • c52.jpg (112.38 kB - 359 times downloaded - Last download: Jul 12th 2008, 7:07pm)
  • c4.jpg (253.57 kB - 349 times downloaded - Last download: Jul 10th 2008, 11:54pm)
  • Go to the top of the page

krsmichael

Beginner

Posts: 50

Location: California

Occupation: Software Engineer

2

Tuesday, February 12th 2008, 4:37am

RE: [cpp] help with c++

How much does this job pay?
  • Go to the top of the page

macabre13

Trainee

Posts: 127

Location: Poland/ Wroclaw

Occupation: sw developer

3

Tuesday, February 12th 2008, 9:02am

And next, people wonder why London does not have a good software developers.
- ebm - noise - industrial -
I always could be wrong.
Lets share knowledge!
  • Go to the top of the page

stinos

Intermediate

4

Wednesday, February 13th 2008, 10:16am

Quoted

Originally posted by macabre13
And next, people wonder why London does not have a good software developers.


because the're unable to do their simple homework assignements

LOL
madinsjamania
  • Go to the top of the page

Rate this thread