Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program 1 Attached Files: // This progam calculates the user's pay. #include using namespace std; int main() { double hours, rate, pay; // Get the
Program 1
Attached Files:
// This progam calculates the user's pay. #includeusing namespace std; int main() { double hours, rate, pay; // Get the number of hours worked. cout << "How many hours did you work? "; cin >> hours; // Get the hourly pay rate. cout << "How much do you get paid per hour? "; cin >> rate; // Calculate the pay. pay = hours * rate; // Display the pay. cout << "You have earned $" << pay << endl; return 0; }In this exercise, we will use our installed C++ compilers to compile pr1-1.cpp program. The exercise will:
- Show how a compiler creates an executable file from a C++ source program
- Familiarize ourselves with the IDE
- Show how the program calculates pay amount based on two inputs from the console
Instructions:
- Download the attached .cpp from Blackboard.
- Open the program using a text editor.
- In your IDE, create a new C++ project. Create a new C++ program. This brings up an IDE editor.
- Copy and paste the program from the text editor to the IDE editor.
- Edit the program and add a line before the return 0; statement.
- On the new line, type the following code: cout << "Submitted by: your-name" << endl;
- Compile (Build) the program and see the output if no errors from compilation.
- Run the program. There will be a console prompt with instructions to enter the hours worked and hourly rate.
- The result of the calculation for pay will be displayed on the console.
- Take a screen image of the results and upload the image to the Blackboard assignment.
Program 2
Attached Files:
// This program has variables of several of the integer types. #includeusing namespace std; int main() { double checking; unsigned int miles; long diameter; checking = -20.50; miles = 4276; diameter = 100000; cout << "We have made a long journey of " << miles; cout << " miles." << endl; cout << "Our checking account balance is " << checking; cout << "The galaxy is about " << diameter; cout << " light years in diameter."; return 0; }In this exercise, we will learn how variables are defined in a program, and various integer data types.
- Download the attached pr2-10.cpp and open in your IDE
- Compile the program.
- Execute the program and make a screen print of the output.
- Upload the screen print to this exercise.
Program 3
Attached Files:
// This program calculates hourly wages, including overtime. #includeusing namespace std; int main() { double regularWages, // To hold regular wages basePayRate = 18.25, // Base pay rate regularHours = 40.0, // Hours worked less overtime overtimeWages, // To hold overtime wages overtimePayRate = 27.78, // Overtime pay rate overtimeHours = 10, // Overtime hours worked totalWages; // To hold total wages // Calculate the regular wages. regularWages = basePayRate * regularHours; // Calculate the overtime wages. overtimeWages = overtimePayRate * overtimeHours; // Calculate the total wages. totalWages = regularWages + overtimeWages; // Display the total wages. cout << "Wages for this week are $" << totalWages << endl; return 0; } In this exercise, we will learn how variables are defined in a program, and various integer data types.
- Download the attached pr2-21.cpp and open in your IDE
- Compile the program.
- Execute the program and make a screen print of the output.
- Upload the screen print to this exercise.
Program 3
Attached Files:
// This program converts seconds to minutes and seconds. #includeusing namespace std; int main() { // The total seconds is 125. int totalSeconds = 125; // Variables for minutes and seconds int minutes, seconds; // Get the number of minutes. minutes = totalSeconds / 60; // Get the remaining seconds. seconds = totalSeconds % 60; // Display the results. cout << totalSeconds << " is equivalent to: "; cout << "Minutes: " << minutes << endl; cout << "Seconds: " << seconds << endl; return 0; }
In this exercise, we will use our installed C++ compilers to compile the downloaded C++ program. The exercise will:
This C++ program uses division. Instructions:
- Download the attached C++ program from Blackboard.
- Open the program using a text editor.
- In your IDE, create a new C++ project. Create a new C++ program. This brings up an IDE editor.
- Copy and paste the program from the text editor to the IDE editor.
- Add a new line before the return 0; statement with this code: cout << "Submitted by: your-name" << endl;
- Compile (Build) the program and see the output if no errors from compilation.
- Run the program. If there are console prompts, enter data requested, otherwise the program is an output only program. Check for errors, if any.
- Take a screen image the results and upload the image to the Blackboard assignment.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started