Related questions with answers
(Data Processing) a. Create a text file containing the following data (without theheadings): b. Write a C++ program that reads the data file created in Exercise 7a and computes and displays a payroll schedule. The output should list the Social Security number, name, and gross pay for each person, calculating gross pay as Hourly Rate Hours Worked.
Name | Social Security Number | Hourly Rate | Hours Worked |
---|---|---|---|
B Caldwell | 555-88-2222 | 7.32 | 37 |
D Memcheck | 555-77-4444 | 8.32 | 40 |
R Potter | 555-77-6666 | 6.54 | 40 |
W Rosen | 555-99-8888 | 9.80 | 35 |
Solution
Verifieda. We’ll create a text file, enter the data and name it
"data.txt"
.
b.
We’ll try to open the file at the beginning of the program and check if
it has opened successfully.
If it has, we’ll declare variables for first name, surname, social
security number, hourly rate and hours worked.
Using the while
loop, we’ll read line by line and store values in
variables, respectively. After reading the data, we’ll calculate the
gross_pay
and display all the data using the cout
.
Create an account to view solutions
Create an account to view solutions
More related questions
1/4
1/7