1. Write a complete C++ program that reads integers from an input file called "numbers.dat". The program should count the number of times zero appeared in the file and print the count on the screen. You can assume that there are 25 numbers in the input file. 2. Write a complete C++ program that reads integers from an input file called "numbers.dat". The program should count the number of times zero appeared in the file and print the count on the screen. The last number in the file will be a sentinel value of -999 to signal that there is no more data. 3. Write a complete C++ program that reads integers from an input file called "numbers.dat". The program should count the number of times zero appeared in the file and print the count on the screen. You do not know how many numbers are in the file and there is no sentinel value at the end of the input. 4. Rewrite the program for Question #3 so that the output is sent to an output file called "out.dat". 5. Write a complete C++ program that will calculate the charge for electricity for customers. The program should read the following information from an input file named "chargin.dat": customer account number (integer) kilowatt hours used (float) status (char) Electric charges are 59 cents per kilowatt hour for commercial customers and 47 cents per kilowatt hours for residential customers. The status will be "r" for residential customers and "c" for commercial customers. You do not know how many lines of data are in the input file. The program should place the following information for each customer in an output file named "chargout.dat": customer account number cost of electricity (float) The output file will be used as input to another program. SAMPLE INPUT FILE: 143 47.3 r 782 245.7 c SAMPLE OUTPUT FILE: 143 22.231 782 144.963 6. Write a complete C++ program that will read the output file produced from Homework Question #5 above and print a bill (to the screen) for each customer. Sample output: Electric Charges Customer: 143 Amount Due: $22.23 Customer: 782 Amount Due: $144.96
Remember to type your answers and to make two copies of each homework assignment. One copy is submitted to me and the other you keep to use in the group discussions.
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2004