Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
9th Edition
ISBN: 9780133862218
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 3.2, Problem 12STE
Write a multiway if-else statement that classifies the value of an int ariable n into one of the following categories and writes out an appropriate message:
n < 0 or 0 ≤ n 100 or n > 100
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a multiway if-else statement that classifies the value of an int variable ninto one of the following categories and writes out an appropriate message:n < 0 or 0 ≤ n < 100 or n ≥ 100Hint: Remember that the Boolean expressions are checked in order.
2.1.3: Basic if-else.
422784.2543518.qx3zqy7
Jump to level 1
Write an if-else statement for the following: If numDifference is less than -15, execute totalDifference = -25. Else, execute totalDifference = numDifference.
CHALLENGE ACTIVITY
4.4.5: Multi-branch if-else statements: Print century.
Write an if-else statement with multiple branches.If year is 2101 or later, print "Distant future" (without quotes). Otherwise, if year is 2001 or greater, print "21st century". Otherwise, if year is 1901 or greater, print "20th century". Else (1900 or earlier), print "Long ago".Sample output with input: 1776 Long ago
Chapter 3 Solutions
Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
Ch. 3.1 - Determine the value, true or false, of each of the...Ch. 3.1 - Name two kinds of statements in C++ that alter the...Ch. 3.1 - In college algebra we see numeric intervals given...Ch. 3.1 - Prob. 4STECh. 3.2 - What output will be produced by the following...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 6...Ch. 3.2 - What would be the output in Self-Test Exercise 6...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 9...
Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - Write a multiway if-else statement that classifies...Ch. 3.2 - Given the following declaration and output...Ch. 3.2 - Given the following declaration and output...Ch. 3.2 - What output will be produced by the following...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - What would be the output in Self-Test Exercise 15...Ch. 3.2 - Prob. 19STECh. 3.2 - Though we urge you not to program using this...Ch. 3.3 - Prob. 21STECh. 3.3 - Prob. 22STECh. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - Prob. 25STECh. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - Prob. 27STECh. 3.3 - For each of the following situations, tell which...Ch. 3.3 - Rewrite the following loops as for loops. a.int i...Ch. 3.3 - What is the output of this loop? Identify the...Ch. 3.3 - What is the output of this loop? Comment on the...Ch. 3.3 - What is the output of this loop? Comment on the...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What is the output of the following (when embedded...Ch. 3.3 - What does a break statement do? Where is it legal...Ch. 3.4 - Write a loop that will write the word Hello to the...Ch. 3.4 - Write a loop that will read in a list of even...Ch. 3.4 - Prob. 38STECh. 3.4 - Prob. 39STECh. 3.4 - What is an off-by-one loop error?Ch. 3.4 - You have a fence that is to be 100 meters long....Ch. 3 - Write a program to score the paper-rock-scissor...Ch. 3 - Write a program to compute the interest due, total...Ch. 3 - Write an astrology program. The user types in a...Ch. 3 - Horoscope Signs of the same Element are most...Ch. 3 - Write a program that finds and prints all of the...Ch. 3 - Buoyancy is the ability of an object to float....Ch. 3 - Write a program that finds the temperature that is...Ch. 3 - Write a program that computes the cost of a...Ch. 3 - (This Project requires that you know some basic...Ch. 3 - Write a program that accepts a year written as a...Ch. 3 - Write a program that scores a blackjack hand. In...Ch. 3 - Interest on a loan is paid on a declining balance,...Ch. 3 - The Fibonacci numbers F are defined as follows. F...Ch. 3 - The value ex can be approximated by the sum 1 + x...Ch. 3 - Prob. 8PPCh. 3 - Prob. 9PPCh. 3 - Repeat Programming Project 13 from Chapter 2 but...Ch. 3 - The keypad on your oven is used to enter the...Ch. 3 - The game of 23 is a two-player game that begins...Ch. 3 - Holy digits Batman! The Riddler is planning his...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Explain the purpose of indexing in database implementation.
Modern Database Management
(Modified Compound-Interest Program) Modify the compound-interest application of Fig. 5.6 to repeat its steps f...
Java How To Program (Early Objects)
(Smallest of Two Numbers) Write a program that defines and uses macro MINIMUM2 to determine the smallest of two...
C How to Program (8th Edition)
It has been suggested that the control software for a radiation therapy machine, used to treat patients with ca...
Software Engineering (10th Edition)
Trace the operation of A search applied to the problem of getting to Bucharest from Lugoj using the straight-li...
Artificial Intelligence: A Modern Approach
Sales Analysis The file SalesData.txt, in this chapters source code folder, contains the dollar amount of sales...
Starting Out with Java: From Control Structures through Objects (6th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Determine whether the following are valid switch statements. if not, explain why. Assume that n and digit are int variables. A. switch (n <= 2) { case 0: cout << "Draw." << endl; break; case 1: cout << "Win." << endl; break; case 2: cout << "Lose." << endl; break; } B. switch (digit / 4) { case 0, case 1: cout << "low." << endl; break; case 1, case 2: cout << "middle." << endl; break; case 3: cout << "high." << endl; } C. switch (n % 6) { case 1: case 2: case 3: case 4: case 5: cout << n; break; case 0: cout << endl; break; } D. switch (n % 10) case 2: { case 4: case 6: case 8: cout << "Even"; break; case 1: case 3: case 5: case 7: cout << "Odd"; break; }arrow_forwardStudy the following if statement: if x>10 or x<-10: print('big') elif x>1000000: print('very big') elif x<-1000000: print('very big') else : print('small') For what values of x will the above code print 'very big'?arrow_forwardWrite a if-elif-else statement that distinguishes between a negative number or 0, a number between 0 and 50, and a number greater than or equal 50 by printing one of these three statements: {"It's negative or zero", "It's between 0 and 50", "It's greater than or equal to 50"}.arrow_forward
- Question: State whether the following are valid switch statements. If not, explain why. Assume that n and digit are int variables. a) switch (n <= 2) { case 0: cout << "Draw." << endl; break; case 1: cout << "Win." << endl; break; case 2: cout << "Lose." << endl; break; } b) switch (digit / 4) { case 0, case 1: cout << "low." << endl; break; case 1, case 2: cout << "middle." << endl; break; case 3: cout << "high." << endl; } c) switch (n % 6) { case 1: case 2: case 3: case 4: case 5: cout << n; break; case 0: cout << end1; break; } d) switch (n % 10) { case 2: case 4: case 6: case 8: cout << "Even"; break; case 1: case 3: case 5: case 7: cout << "Odd"; break; }arrow_forwardWrite a VB program to ask user to assign a value to “i” to find the answer for the following three cases. Case 1. Assume i = 1 and HowMuch = 0 IF i < 5 THEN HowMuch = HowMuch + 1 ELSEIF i = 5 THEN HowMuch = HowMuch - 5 ELSE HowMuch = HowMuch + 3 END IF DISPLAY HowMuch Case 2. Assume i = 5 and HowMuch = 0 IF i < 5 THEN HowMuch = HowMuch + 1 ELSEIF i = 5 THEN HowMuch = HowMuch - 5 ELSE HowMuch = HowMuch + 3 END IF DISPLAY HowMuch Case 3. Assume i = 6 and HowMuch = 0 IF i < 5 THEN HowMuch = HowMuch + 1 ELSEIF i = 5 THEN HowMuch = HowMuch - 5 ELSE HowMuch = HowMuch + 3 END IF DISPLAY HowMucharrow_forwardWrite a VB program to ask user to assign a value to “i” to find the answer for the following three cases. 1. Case 1. Assume i = 1 and HowMuch = 0IF i < 5 THENHowMuch = HowMuch + 1ELSEIF i = 5 THENHowMuch = HowMuch - 5ELSEHowMuch = HowMuch + 3END IFDISPLAY HowMuch2. Case 2. Assume i = 5 and HowMuch = 0IF i < 5 THENHowMuch = HowMuch + 1ELSEIF i = 5 THENHowMuch = HowMuch - 5ELSEHowMuch = HowMuch + 3END IFDISPLAY HowMuch3. Case 3. Assume i = 6 and HowMuch = 0IF i < 5 THENHowMuch = HowMuch + 1ELSEIF i = 5 THENHowMuch = HowMuch - 5ELSEHowMuch = HowMuch + 3END IFDISPLAY HowMucharrow_forward
- IN C LANGUAGE USING LADDERIZED IF-ELSE Create a program that will calculate Body Mass Index (BMI) and will indicate the status of your BMI. Using ladderized if-else. BMI = ([Weight in Pounds) / (Height in inches) x (Height in inches)] x 703 BMI = (Weight in Kilograms) / (Height in meters) x (Height in meters) Your program must accept weight in pounds or kilogram, and height in inches or meters. Formula: 1 ft = 12 inches 1 meter = 39.3701 iches 1 in = 0.0254 m 1 kg = 2.2 lb 1 lb = 0.454 kg BMI Categories: Underweight = <18.5 Normal weight = 18.5 - 24.9 Overweight = 25 - 29.9 Obesity = BMI of 30 or greater Sample Program: Weight (Input 1 for Lb, input 2 for kg): 1 Input weight in Lb: 220 Height (Input 1 for inches, input 2 for meters): 2 Input height in meters: 2 Your BMI is: 24.9 BMI Category: NORMAL WEIGHTarrow_forwardCorrect the following code so that it prints the correct message. (3)if (score <= 60)cout << "Pass" << endl;else;cout << "Fail" << endl; 16.What is the output of the following C++code? (2, 5, 6)int x = 15; int y = 3; if (x + y > {y = x -x = y +cout << x << " " << y << " " << x + y << " " << y - x << endl;}else{x = y - x + y %5;cout << x << " " << y << " " << x - y << " " << x + y << endl; } 21.Suppose that score is an int variable. Consider the following ifstatements. (3)if (score >= 90);cout << "Discount = 10%" << endl;a. What is the output if the value of score is 95? Justify your answer.b. What is the output if the value of score is 85? Justify your answer. 22.Suppose that score is an int variable. Consider the following ifstatements. (3)i. if (score == 70)cout << "Grade is C." << endl;ii. if (score = 70)cout << "Grade is C."…arrow_forwardWrite an equivalent if...else if...else statement to replace the following switch statement int cents; switch (cents) { case 1: System.out.println("Cent."); break; case 5: System.out.println("Nickle."); break; case 10: System.out.println("Dime."); break; case 25: System.out.println("Quarter."); break; default: System.out.println("Not a valid value."); }arrow_forward
- Convert the following C++ code from if-Statement to switch-statement, such that it gives the same output. int x;cin >> x;if (x == 1)cout << “EXCELLENT”;else if ((x == 2) || (x == 3) || (x == 4))cout << “GOOD”;elsecout << “BYE BYE”;arrow_forwardWrite a C++ program that : You have to do the following question only by nested if-statement. FROM GRADE A TO F A 93-100% 4.00 A- 90-92% 3.70 B+ 87-89% 3.30 B 83-86% 3.00 B- 80-82% 2.70 C+ 77-79% 2.30 C 73-76% 2.00 C- 70-72% 1.70 D+ 67-69% 1.30 D 63-66% 1.00 D- 60-62% 0.70 F Ask user to enter a grade and then determine the letter grade. Sample output: What is your grade: 94 Your grade on your trascript would be A.arrow_forwardWrite an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future" (without quotes). Else, if givenYear is 2001 or greater (2001-2100), print "21st century". Else, if givenYear is 1901 or greater (1901-2000), print "20th century". Else (1900 or earlier), print "Long ago". End with a newline. Remember to use println instead of print to output a newline.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY