Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

101 John Smith 65 78 65 89 25 98 -999 102 Peter Gupta 87 34 89 99 26 78 64 34 -9

ID: 3742453 • Letter: 1

Question

101

John Smith

65 78 65 89 25 98 -999

102

Peter Gupta

87 34 89 99 26 78 64 34 -999

103

Buddy Friend

23 99 98 97 26 78 100 63 87 23 -999

104

Doctor Miller

62 35 78 99 12 93 19 -999

-Write C++ statements that include the header files iostream and string.

-Write a C++ statement that allows you to use cin, cout, and endl without the prefix std::.

-Write C++ statements that declare and initialize the following named constants: SECRET of type int initialized to 11 and RATE of type double initialized to 12.50.

-Write C++ statements that declare the following variables: num1, num2, and newNum of type int; name of type string; and hoursWorked and wages of type double.

-Write C++ statements that prompt the user to input two integers and store the first number in num1 and the second number in num2.

-Write a C++ statement(s) that outputs the values of num1 and num2, indicating which is num1 and which is num2. For example, if num1 is 8 and num2 is 5, then the output is:

-

Write a C++ statement that multiplies the value of num1 by 2, adds the value of num2 to it, and then stores the result in newNum.

Write a C++ statement that outputs the value of newNum.

Write a C++ statement that updates the value of newNum by adding the value of the named constant SECRET to it.

Write a C++ statement that outputs the value of newNum with an appropriate message.

Write C++ statements that prompt the user to enter a person’s last name and then store the last name into the variable name

Write C++ statements that prompt the user to enter a decimal number between 0 and 70 and then store the number entered into hoursWorked.

Write a C++ statement that multiplies the value of the named constant RATE with the value of hoursWorked and then stores the result into the variable wages.

Write C++ statements that produce the following output:

For example, if the value of name is Rainbow and hoursWorked is 45.50, then the output is:

Explanation / Answer

#include <iostream>
using namespace std;

int main() {
const int SECRET= 11;
const double RATE = 12.50;
int num1, num2, newNum ;
string name;
double hoursWorked ,wages;

cout<<"input two integers";
cin>>num1>>num2;

cout<<endl;
cout<<"num1 = "<<num1<<endl;
cout<<"num2 = "<<num2<<endl;
newNum = num1 * 2 + num2;

cout<<" newNum = "<<newNum;
newNum += SECRET;

cout<<" Adding SECRET to newNum = "<<newNum;

cout<<" Enter a person’s last name"<<endl;
cin>> name;

cout<<"Enter a decimal number between 0 and 70 ";
cin>> hoursWorked;
wages = RATE * hoursWorked ;

cout<<" Name: "<<name<<endl;     //output the value of the variable name
cout<<"Pay Rate: $"<<RATE<<endl;     //output the value of the RATE
cout<<"Hours Worked: "<<hoursWorked<<endl; //output the value of the variable //hoursWorked
cout<<"Salary: $"<<wages;     //output the value of the variable //wages

return 0;
}

Output:

input two integers 8 5
num1 = 8
num2 = 5

newNum = 21
Adding SECRET to newNum = 32
Enter a person’s last name Rainbow
Enter a decimal number between 0 and 70 45.50
Name: Rainbow
Pay Rate: $12.5
Hours Worked: 45.5
Salary: $568.75

Do ask if any doubt. Please upvote.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote