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

Consider the following program segment: //include statement(s) //using namespace statement intmain() { //variable declaration //executable statements //return statement }

a. Write C++ statements that include the header filesiostream and string.

b. Write a C++ statement that allows you to usecin, cout, and endl without the prefixstd::.

c. Write C++ statements that declare and initialize the following named constants: SECRET of typeintinitialized to 11 and RATE of type doubleinitialized to 12.50.

d. Write C++ statements that declare the following variables:num1,num2, andnewNumof typeint; nameof typestring; andhoursWorkedand wagesof typedouble.

e. Write C++ statements that prompt the user to input two integers and store the first number in num1and the second number innum2. 2 Programming Exercises | 111

f. Write a C++ statement(s) that outputs the values ofnum1andnum2, indicating which is num1and which isnum2. For example, if num1is 8 andnum2is 5, then the output is: Thevalueofnum1=8andthevalueofnum2=5.

g. Write a C++ statement that multiplies the value ofnum1by2, adds the value ofnum2to it, and then stores the result innewNum. Then, write a C++ statement that outputs the value ofnewNum.

h. Write a C++ statement that updates the value ofnewNumby adding the value of the named constant SECRET. 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 variablename

. j. Write C++ statements that prompt the user to enter a decimal number between0and70and then store the number entered intohoursWorked.

k. Write a C++ statement that multiplies the value of the named constant RATEwith the value ofhoursWorkedand then stores the result into the variablewages.

l. Write C++ statements that produce the following output

: Name: //output the value of the variable name PayRate:$ //output the value of the variable rate HoursWorked: //output the value of the variable //hoursWorked Salary:$

//output the value of the variable wages For example, if the value ofnameis "Rainbow"andhoursWorkedis 45.50, then the output is: Name:Rainbow PayRate:$12.50 HoursWorked: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 previous C++ program segment. 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!