/* decisionsLab.cpp Name: CIS 150 Date: CIS 150 Chapter 4 Decisions Lab */ /* Place your name and section at the top in comments. Read the instructions for each question and give your answer in comments or write the code into the program. You may comment out sections as you work. Declare variables if necessary. You do not need to get input from the user unless otherwise specified or that code is already written. */ #include #include #include using namespace std; int main() { cout << "Part 1\n"; for (int age=50; age<=80; age=age+15) { cout << "Testing with age = " << age << '\n'; float admission = 0.0; /* Part 1. Find and fix the error(s) in the following code. if (age > = 65); cout <<"Age greater than or equal to 65\n"; admission = 10.0; else cout << "Age is less than 65\n"; admission = 15.0; cout << "Admission: " << fixed << showpoint << setprecision(2) << admission << '\n'; */ } cout << "\nPart 2\n"; for (int count=5; count<=15; count+=5) { cout << "Testing with count = " << count << '\n'; /* Part 2. Find and fix the error(s) in the following code. if (count = 10) cout << "The count is 10\n"; else cout << "The count is NOT 10\n"; */ } cout << "\nPart 3\n"; for (int score=-50; score<=150; score+=50) { cout << "Testing with score = " << score << '\n'; /* Part 3. Find and fix the error(s) in the following code. // checking to see of score is less than 0 or greater than 100 if (0 > score > 100) cout << "The score is out of range\n"; else cout << "The score is in range\n"; */ } cout << "\nPart 4\n"; cout << "1. Enter data and save to file\n" << "2. Read data in and display report\n" << "3. Quit the program\n"; for (int option=-1; option<=4; option++) { cout << "Testing with option = " << option << '\n'; /* Part 4. Write a switch statement that will display a simple message telling the user which option was chosen. For example, if the option chosen was 2, output "Read data". Display an invalid entry message if the option chosen is something other than 1, 2, or 3. For testing purposes the option will be chosen by a loop variable rather than getting actual user input. */ } cout << "\nPart 5\n"; for (double sales=0.0; sales<=25000.0; sales+=2500.0) { cout << "Testing with sales = $" << fixed << showpoint << setprecision(2) << sales << '\n'; double rate = 0.0; /* Part 5. Write a decision structure that will set the variable rate to the proper value based on the value of sales. Follow these rules: No commision is paid for sales of 0 or less. A sales commision of 2% (.02) is paid for sales over 0 up to 10,000. A sales commision of 3% (.03) is paid for sales over 10,000 up to 15,000. A sales commision of 4% (.04) is paid for sales over 15,000 up to 20,000. A sales commision of 5% (.05) is paid for sales over 20,000. // write your code to set the rate here cout << "The commission is $" << rate * sales << endl; */ } // cross platform pause if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); return 0; }