Question: Follow the instructions for starting your C++ development tool. Depending on the development tool you are using, you may need to create a new project;
Follow the instructions for starting your C++ development tool. Depending on the development tool you are using, you may need to create a new project; if so, name the project Lab7-2 Project, and save it in the Cpp8\Chap07 folder. Enter the instruc- tions shown in Figure 7-44 in a source file named Lab7-2.cpp. (Do not enter the line numbers.) Save the file in either the project folder or the Cpp8\Chap07 folder. Now follow the appropriate instructions for running the Lab7-2.cpp file. Test the program using 125000 as the current sales amount. If necessary, correct any bugs (errors) in the program.
1 //Lab7-2.cpp - Displays the number of years required 2 //for a company's sales to reach at least $150,000 3 //using a 5.5% annual growth rate. Also displays 4 //the sales at that time. 5 //Created/revi sed by on 6 7 #include 8 #include 9 using namespace std; 10 11 int main() 12 { 13 const double GROWTH_RATE = 0.055; 14 double sales = 0.0; 15 double annual Increase = 0.0; 16 int years = 0; 17 18 cout "Current year's sales: "; 19 cin sales; 20 while (sales < 150000.0) 21 { 22 annual Increase = sales * GROWTH_RATE; 23 sales += annual Increase ; 24 years += 1; 25 } //end while 26 27 cout fixed setprecision(O) ; 28 cout "Sales " years " years from now: $" 29 sal es endl ; 30 31 return 0; 32 } //end of main function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
