Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5-23 Program for Lab 5-1 The answers to the labs are contained in the Answers.pdf file. 1 //Lab5-1.cpp - displays projected sales 2 //Created/revised by

5-23 Program for Lab 5-1

The answers to the labs are contained in the Answers.pdf file.

1 //Lab5-1.cpp - displays projected sales 2 //Created/revised by on 3 4 #include 5 #include 6 using namespace std; 7 8 int main() 9{

10 double sales = 0.0; 11 double rate = 0.0; 12 char code = ' '; 13

14 cout << "Sales: "; 15 cin >> sales; 16 cout << "Code (1, 2, 3, or 4): "; 17 cin >> code; 18 19 if (code == '1' || code == '3') 20 rate = 0.2; 21 else 22 rate = 0.15; 23 //end if 24 25 //calculate and display the projected sales amount 26 sales = sales + sales * rate; 27 cout << fixed << setprecision(2); 28 cout << "Projected sales: " << sales << endl; 29 30 return 0; 31 } //end of main function

1. What rate will be assigned to the rate variable when the user enters the following codes:

1, 3, 2, 4, and 5?

2. Why is the directive on Line 5 necessary?

3. Why are the literal constants on Line 19 enclosed in single quotation marks?

4. How would you rewrite the if statement on Lines 19 through 23 to use the != operator in the condition?

5. How else could you write the statement on Line 26? 6. What changes would you need to make to the program so that it doesnt use the rate

variable

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

=+ Are unions company-wide, regional, or national?

Answered: 1 week ago