Question: Consider the following program segment: //include statement(s) //using namespace statement int main() { //variable declaration //executable statements //return statement } A. Write C++ statements that

Consider the following program segment:

//include statement(s) //using namespace statement int main() { //variable declaration //executable statements //return statement }

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

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

C. 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.

D. 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.

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

F. 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:

The value of num1 = 8 and the value of num2 = 5.

G. 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. Then, write a C++ statement that outputs the value of newNum.

H. Write a C++ statement that updates the value of newNum by adding the value of the named constant SECRET to it. Then, write a C++ statement that outputs the value of newNum with an appropriate message.

I. Write C++ statements that prompt the user to enter a persons last name and then store the last name into the variable name.

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

K. 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.

L. Write C++ statements that produce the following output:

Name: //output the vlaue of the variable name Pay Rate: $ //output the value of the Rate Hours Worked: //output the value of the variable hoursWorked Salary: $ //output the value of the variable wages

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

Name: Rainbow Pay Rate: $12.50 Hours Worked: 45.50 Salary: $568.75

M. Write a C++ program that tests each of the C++ statements that you wrote in parts a through l. Place the statements at the appropriate place in the C++ program segment given at the beginning of this problem. Test run your program (twice) on the following input data:

a. num1 = 13, num2 = 28; name ="Jacobson"; hoursWorked = 48.30.

b. num1 = 32, num2 = 15; name ="Crawford"; hoursWorked = 58.45.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!