Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ (A straight forward exercise in processing structs) Textbook Reference: Chapter 11 Write a program that accepts 3 pieces of data (ID Number, # of

C++
(A straight forward exercise in processing structs)
Textbook Reference:
Chapter 11
Write a program that accepts 3 pieces of data (ID Number, # of hours taken, and # of credit points earned) for a student and computes and prints the students GPA. The data is to be entered from the keyboard, with each loop producing one line of the output below.
Hint: This program can be coded much like Program 11-1 on page 605 in the textbook, except you will have a loop to process several lines of output. Note: No array is needed since we just want to print output not store the data. So, each pass of the loop allows the user to enter data for a student, then prints that students output line. In order to not have the lines that prompt the user for input to get mixed into the output shown below, you will need to write the output shown below to a text file and copy the lines in the text file to this turn in sheet as your program output.
The data should be stored in the following structure type:
struct StudentType
{
int idNum,
creditPts,
creditHours;
double gpa;
}
Use the data below and format your output to appear as shown, with an additional column for GPA. Output should show the GPA with 2 decimal places.
Note: GPA is calculated as Credit Points divided by Credit Hours
ID Credit Points Credit Hours
1086 37 12
1198 124 37
9872 124 40
1112 124 46
2348 125 50
5577 312 125
Lab Task 2 Pay Me Please
(An exercise in processing structs)
Textbook Reference:
Chapter 11
Write a program that accepts 4 pieces of data [ID Number, # of hours worked, hourly pay rate, and a percentage (12 = 12% = 0.12) for the tax deduction ] for an employee and then computes and prints the employees net pay. Hint: This program can be coded much like program 11-4 on page 612 in the textbook.
Assume overtime (over 40 hours) is paid at time and a half.
The data should be stored in an array of structs of the following structure type:
Struct EmployeeType
{
int idNum,
hoursWorked;
float hourlyPayRate;
float taxRate;
}
Turn in printouts for the data below:
ID Hours Worked Rate Of Pay Tax Rate(%)
1086 40 6.50 10
1125 35 12.00 15
2344 40 66.00 28
9972 60 45.00 28
3446 20 9.75 10
A typical line of output should appear as:
ID Hours Worked Rate Of Pay Tax Rate Gross Pay Net Pay
1086 40 6.50 10 $260.00 $234.00
NOTE: Please create a loop in your code so all data can be entered in a single run. After all data is entered in the array use another loop to print the 5 lines of output. Output MUST be formatted identically to the line above.
A suggestion for producing output: Write the 6 lines of output (one header line followed by 5 data lines) to a text file, then copy the text file content to your turn in document.
Recall:
#include
ofstream outfile("output.txt");
Now use outfile like you have been using cout and it writes to the file instead of the screen.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started