Lab 7-2, #19, Lab 8-2, #18

1 answer below »
Lab 7-2, #19, Lab 8-2, #18
Answered Same DayMar 26, 2021

Answer To: Lab 7-2, #19, Lab 8-2, #18

Meenakshi answered on Mar 29 2021
151 Votes
labworkcpp/chapter7/#18.pdf
274
More on the Repetition Structure
INTERMEDIATE 76. In this exercise, you rvil1 modify the program from Lab 7 -2 in Chapter 7 .If
create a nen, project named Intermediate16 Project, and save it in the
folder. Copy the instructions from the LabT -2.cpp file into a source file nameci.
mediatel6.cpp. The LabT -2.cpp file is contained in either the CppB\Chap07\La:-'-
Project folder or the Cpp8\ChapO7 folder. (Alternatively, you can enter the
from Figure 7 -44 into the Intermediatel6.cpp file.) Change the filename in the :-:r
comment. Modify the program to al1ow the user to display the output for any
of sales amounts. Save and then run the program. Test the program twice, using sa{
amounts of125000 and 96000. fl
INTE RM E DIATE 77. In this exercise, you rvi1l modify the program from Lab 7-1 in Chapter 7. Follou' i-=
instructions for starting C++ and vieu,ing the IntermediatelT.cpp file, which is cc. '
tained in either the CppB\Chap08\lntermediatelT Project folder or the Cpp8\Cha: - :
folder. (Depending on your C++ development tool, you may need to open the pro'. *
solution f
ile first.) Currently, the program displays the average number of text mes-
sages sent each day for one week. Modify the program so that it also displays the
average number of text messages sent each rveek for four weeks. Test the program
appropriately.
18. At the beginning of every year, I(halid receives a raise on his previous year's salar1'. :-i.
wants a program that calculates and displays the amount of his annual raises for the
next three years, using rates of 3%, 4%, 5o/o, and 6o/o. The program should end when
Khalid enters a sentinel value as the salary.
a. Create an iPO chart for the problem, and then desk-check the algorithm using
annual salaries of 30000 and 50000, followed by your sentinel value.
b. List the input, processing, and output items, as well as the algorithm, in a chart
similar to the one shown earlier in Figure 8-16. Then code the algorithm into a
program.
c. Desk-check the program using the same data used to desk-check the algorithm.
d. If necessary, create a new project named IntermediatelB Project, and save it in
the Cpp8\Chap08 folder. Enter your C++ instructions into a source file named
IntermediatelS.cpp. Also enter appropriate comments and any additional
instructions required by the compiler.
e. Save and then run the program. Test the program using the same data used to
desk-check the program.
79. Create a program that allows the user to enter an unknown number of sales
amounts for each of three car dealerships: Dealership 1, Dealership 2, and
Dealership 3. The program should calculate the total sales. Display the total sales
with a dollar sign and trvo decimal places.
a. Create an IPO chart for the problem, and then desk-check the algorithm using
23000 and 15000 as the sales amounts for Dealership 1; 12000, 16000, 34000, and
10000 for Dealership 2; and 64000, 12000, and 70000 for Dealership 3.
b. List the input, processing, and output items, as well as the algorithm, in a chart
similar to the one shown earlier in Figure 8-16. Then code the algorithm into a
program.
INTERMEDIATE
INTERMEDIATE
labworkcpp/chapter7/intermediate7.16.cpp
labworkcpp/chapter7/intermediate7.16.cpp
 //Lab7-2.cpp - Displays the number of years required
  //for a company's sales to reach at least $1-50,000
//using a 5.5% annual growth rate. Also displays
//the sales at that time.
//Created/re$sed by  on 
 #include 
#include 
 using namespace std;
 
int main()
{
const double GROWTHRATE = 0.055;
double sales=0.0;
double annualIncrease = 0.0;
int years = 0;
cout << "Current Year's sales: ";
cin>>sales;
while (sales>125000 && sales<=965000)
{
annualIncrease = sales*GROWTHRATE;
sales += annualIncrease;
years += 1;
}
cout << fixed << setprecision(0);
cout << "Sales " << years << " years from now"<< sales << endl;
return 0; //end of main function 31_
}
labworkcpp/chapter7/intermediate7.16.exe
labworkcpp/chapter7/lab7.2.cpp
labworkcpp/chapter7/lab7.2.cpp
 //Lab7-2.cpp - Displays the number of years required
  //for a company's sales to reach at least $1-50,000
//using a 5.5% annual growth rate. Also displays
//the sales at that time.
//Created/re$sed by  on 
 #include 
#include 
 using namespace std;
 
int main()
{
const double GROWTHRATE = 0.055;
double sales=0.0;
double annualIncrease = 0.0;
int years = 0;
cout << "Current Year's sales: ";
cin>>sales;
while (sales < 150000.0)
{
annualIncrease = sales*GROWTHRATE;
sales += annualIncrease;
years += 1;
}
cout << fixed << setprecision(0);
cout << "Sales " << years << " years from now"<< sales << endl;
return 0; //end of main function 31_
}
labworkcpp/chapter7/lab7.2.exe
labworkcpp/chapter7/__MACOSX/._#18.pdf
labworkcpp/CHAPTER8/#18.pdf
274
More on the Repetition Structure
INTERMEDIATE 76. In this exercise, you rvil1 modify the program from Lab 7 -2 in Chapter 7 .If
create a nen, project named Intermediate16 Project, and save it in the
folder. Copy the instructions from the LabT -2.cpp file into a source file nameci.
mediatel6.cpp. The LabT -2.cpp file is contained in either the CppB\Chap07\La:-'-
Project folder or the Cpp8\ChapO7 folder. (Alternatively, you can enter the
from Figure 7 -44 into the Intermediatel6.cpp file.) Change the filename in the :-:r
comment. Modify the program to al1ow the user to display the output for any
of sales amounts. Save and then run the program. Test the program twice, using sa{
amounts of125000 and 96000. fl
INTE RM E DIATE 77. In this exercise, you rvi1l modify the program from Lab 7-1 in Chapter 7. Follou' i-=
instructions for starting C++ and vieu,ing the IntermediatelT.cpp file, which is cc. '
tained in either the CppB\Chap08\lntermediatelT Project folder or the Cpp8\Cha: - :
folder. (Depending on your C++ development tool, you may need to open the pro'. *
solution file first.) Currently, the program displays the average number of text mes-
sages sent each day for one week. Modify the program so that it also displays the
average number of text messages sent each rveek for four weeks. Test the program
appropriately.
18. At the beginning of every year, I(halid receives a raise on his previous year's salar1'. :-i.
wants a program that calculates and displays the amount of his annual raises for the
next three years, using rates of 3%, 4%, 5o/o, and 6o/o. The program should end when
Khalid enters a sentinel value as the salary.
a. Create an iPO chart for the problem, and then desk-check the algorithm using
annual salaries of 30000 and 50000, followed by your sentinel value.
b. List the input, processing, and output items, as well as the algorithm, in a chart
similar to the one shown earlier in Figure 8-16. Then code the algorithm into a
program.
c. Desk-check the program using the same data used to desk-check the algorithm.
d. If necessary, create a new project named IntermediatelB Project, and save it in
the Cpp8\Chap08 folder. Enter your C++ instructions into a source file named
IntermediatelS.cpp. Also enter appropriate comments and any additional
instructions required by the compiler.
e. Save and then run the program. Test the program using the same data used to
desk-check the program.
79. Create a program that allows the user to enter an unknown number of sales
amounts for each of three car dealerships: Dealership 1, Dealership 2, and
Dealership 3. The program should calculate the total sales. Display the total sales
with a dollar sign and trvo decimal places.
a. Create an IPO chart for the problem, and then desk-check the algorithm using
23000 and 15000 as the sales amounts for Dealership 1; 12000, 16000, 34000, and
10000 for Dealership 2; and 64000, 12000, and 70000 for Dealership 3.
b. List the input, processing, and output items, as well as the algorithm, in a chart
similar to the one shown earlier in Figure 8-16. Then code the algorithm into a
program.
INTERMEDIATE
INTERMEDIATE
labworkcpp/CHAPTER8/#19.pdf
Exercises
15. Create a program that aIIou.s the user to enter the ages (in years) of five people. The
program should display the average age. Use the fo r statement. Display the average age
with one decimal place. If necessary, create a new project named TryThisl5 Project, and
save it in the Cpp8\Chap07 folder. Enter the C++ instructions into a source file named
TryThisl5.cpp. Also enter appropriate comments and any additional instructions
required by the compiler. Test the program using the following ages: 23, 31,37 ,19, and
43. (The answers to TRY THIS Exercises are located at the end of the chapter.)
16. In this exercise, you will modify the tip program shown earlier in Figure 7-31. Follow
the instructions for starting C++ and vierving the ModifyThisl6.cpp file, which is con-
tained in either the Cpp8\ChapO7\ModifyThisl6 Project folder or the Cpp8\Chap07
folder. (You may need to open the project/soiution file first.) Change the for statement
to a whi I e statement. Save and then run the program. Test the program using 90.50 as
the restaurant bi1l. The three tips should appear as shown earlier inFigureT-32.
17 . In this exercise, you will modify the sales program from LabT -2. If necessary, create a
new project named ModifyThislT Projecf, and save it in the CppB\ChapO7 folder. Enter
(or copy) the LabT -2.cpp instructions into a new source file named ModifyThislT.cpp.
Change LabT -2.cpp in the first comment to ModifyThislT.cpp. In addition to the
current output, the program should also display the annual increase amounts. Display
each amount on a separate line, using the message "Year x increase: $y'l in which x is the
year number and y is the increase amount. The increase amounts should be displayed
with no decimal piaces. Save and then run the program. Enter 125000 as the current
year's sales. (Hint: The first line in the output should say "Year 1 increase: $6875':)
18. Create a program that displays the weekly gross pay for any number of employees. The
user wiil input the number of hours the employee worked and the employee's hourly
rate. Employees working more than 40 hours receive time and one-ha1f for the hours
worked over 40. Ifnecessary, create a new project named IntroductorylB Project, and
save it in the Cpp8\ChapO7 folder. Enter the C++ instructions into a source file named
Introductoryl8.cpp. Also enter appropriate comments and any additional instructions
required by the compiier. Save, run, and test the program.
19. Create a program that a teacher can use to enter the midterm and final test scores for
any number of students. Each test is rvorth 200 points. The program should display
each student's grade, which is based on the total points the student earned, as indicated
in Figure 7-50.If necessar)r, create a new project named Introductoryl9 Project, and
save it in the Cpp8\Chap07 folder. Enter the C++ instructions into a source file named
Introductorylg.cpp. Also enter appropriate comments and any additional instructions
required by the compiler. Save, run, and test the program.
MODIFY THIS
MODIFY THIS
INTRODUCTORY
INTRODUCTORY
Total...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here