CS 116 Programming in C++ Lab #6B Painting
Objectives
To learn to plan, code, compile and run a program using file
input and file output, using modular design and passing
parameters.
Assignment
Plan and code a modular program (you must use 3
modules) utilizing file for input and file output to
solve the following problem:
Write a complete modular program in C++ to calculate painting
costs for customers of Top Quality Home Painting Service. All data
will be input from a file (see below). Input data from a
file. You must use 3 modules: one for data
input (and error handling), one for calculations, and one module
for outputting data to the output file. All errors must be
checked for in the input module and sent to an error
file.
Determine the cost for interior painting, the cost for exterior
painting, and the cost for the entire paint job in the calculate
module. No calculations should be done if there is any error
in the input data for that record.
Label and output all data (customer initials, customer account
number, interior square feet, cost per interior square feet,
exterior square feet, cost per exterior square feet, total interior
cost, total exterior cost, and total cost) to an output file in the
output module. If any data record contains an error, output the
data to an error file with a message indicating what caused the
error ONLY in the input module.
Input
Input data from a file (Paint.txt). One record
of data contains the following sequence of data:
ABC 1234 400 3.50 850 5.50
3 customer initials, customer account number (integer), the
number of interior square feet to be painted, the cost per square
foot for interior painting, the number of exterior square feet to
be painted, the cost per square foot for exterior painting. Create
the data file below using your text editor or
Notepad. Name the data file
"Paint.txt."
Data File
ABC 1234
400 3.50
850 5.50
DEF 1345
100 5.25
200 2.75
GHI 2346
200 10.00
0 0.0
JKL 4567
375 4.00
50 4.00
MNO 5463
200
-5.0
150 3.00
PQR 679
0
0.0
100 3.50
STU 6879
100
0.0
-100 0.0
VWX 7348
0
0.0
750 0.0
XYZ 9012
-24
5.00
-50 5.00
AAA 8765
100 6.00
150 4.50
Output
Output and label all input and calculated data (three initials,
customer account number, interior square feet, cost per interior
square feet, exterior square feet, cost per exterior square feet,
total interior cost, total exterior cost, and total cost for valid
data) to an output file (PaintOut.txt). Output
valid data to one file and output errors to an error file
(PaintError.txt). Be sure to output
all record data, clearly labeled and formatted.
Note
Label all output clearly. Be sure your output file contains what
was entered in addition to the all the detailed results of your
program calculations.
Estimate
Account
: 1345
Exterior Area
: 200
Exterior Price
: 2.75
Exterior Cost :
550.00
Interior Area
: 100
Interior Price
: 5.25
Interior Cost :
525.00
Total Cost
: 1075.00
Output
Itemized estimate listing all data for each customer (similar to
shown above) containing each separate charge and total charge to a
file. Label all output clearly. Errors must be sent to an
error file(PaintError.txt), clearly
labeled. Do not calculate costs for error data.
You may NOT use return or break or exit to prematurely exit
the program. Exit may only be used to check for correctly opened
files - nowhere else in any program. Break may only be used
in switch statements - nowhere else in any program.
No arrays, no pointers. You may NEVER use goto or
continue statements in any program.
CS 116 Programming in C++ Lab #6B Painting Objectives To learn to plan, code, compile and run a program using file inp
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
CS 116 Programming in C++ Lab #6B Painting Objectives To learn to plan, code, compile and run a program using file inp
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!