Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 4.12, Problem 4.40CP
Complete the following
cout << "Enter one of the numbers 1, 2, or 3: ";
cin >> userNum;
// Write the switch statement here.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
True or False The test expression in a switch statement can be a double or a decimal value.
Number 3: Write a pseudocode and draw a flowchart to read age of a user. You should display the suitable message by using the following scheme: 0-5 - Baby6-14 - Child15-35 - Young36-55 - Middle aged56 & above - old
Problem definition:
A college wants to know how well its students did on an exam. The following program summarizes the results. The
program asks a user to enter the results pass (1) or fail (2) for 10 students. It displays the number of passed and the
number of failed. It displays a message "Raise error" if the number of passes is more than 8
You are asked to identify statement with syntax errors by selecting them as wrong and the correct statements as
right
Chapter 4 Solutions
Starting Out with C++: Early Objects (9th Edition)
Ch. 4.1 - Prob. 4.1CPCh. 4.1 - Indicate whether each of the following statements...Ch. 4.1 - Prob. 4.3CPCh. 4.1 - What will the following program segment display?...Ch. 4.2 - Write an if statement that performs the following...Ch. 4.2 - Write an if statement that multiplies payRate by...Ch. 4.2 - Write an if statement that performs the following...Ch. 4.2 - TRUE or FALSE: Both of the following if statements...Ch. 4.2 - Write an if statement that performs the following...Ch. 4.2 - Write an if statement that prints The performance...
Ch. 4.2 - Although the following code segments are...Ch. 4.3 - Write an if/else statement that assigns 0.10 to...Ch. 4.3 - Write an if / else statement that assigns 1 to x...Ch. 4.3 - Write an if /else statement that assigns .10 to...Ch. 4.3 - True or false: The following if / else statements...Ch. 4.3 - Will the if / else statement shown on the right...Ch. 4.4 - What will the following program segment display?...Ch. 4.4 - The following program is used in a bookstore to...Ch. 4.4 - Write an if/else if statement that carries out the...Ch. 4.4 - Write an if/else if statement that performs the...Ch. 4.6 - If you execute the following code, what will it...Ch. 4.6 - If you execute the following code, what will it...Ch. 4.7 - Prob. 4.23CPCh. 4.7 - If a = 2, b = 4, and c = 6, indicate whether each...Ch. 4.7 - If a = 2, b = 4, and c = 6, is the following...Ch. 4.7 - Rewrite the following using the ! operator so that...Ch. 4.9 - Write an if statement that prints the message The...Ch. 4.9 - Write an if statement that prints the message The...Ch. 4.9 - Find and fix the errors in the following code...Ch. 4.10 - Prob. 4.30CPCh. 4.10 - Indicate whether each of the following relational...Ch. 4.10 - Prob. 4.32CPCh. 4.10 - Indicate whether each of these character testing...Ch. 4.11 - Rewrite the following if / else statements as...Ch. 4.11 - Rewrite the following conditional expressions as...Ch. 4.11 - Prob. 4.36CPCh. 4.12 - Explain why you cannot convert the following i...Ch. 4.12 - What is wrong with the following switch statement?...Ch. 4.12 - What will the following program segment display?...Ch. 4.12 - Complete the following program segment by writing...Ch. 4.12 - Rewrite the following program segment using a...Ch. 4.13 - Prob. 4.42CPCh. 4.13 - Follow the instructions to complete the following...Ch. 4 - An expression using the greater-than, less-than,...Ch. 4 - Prob. 2RQECh. 4 - The if statement regards an expression with the...Ch. 4 - For an if statement to conditionally execute a...Ch. 4 - In an if / else statement, the if part executes...Ch. 4 - The trailing else in an if / else if statement has...Ch. 4 - If the subexpression on the left of the logical...Ch. 4 - If the subexpression on the left of the || logical...Ch. 4 - The ____ logical operator has higher precedence...Ch. 4 - Logical operators have _____ precedence than...Ch. 4 - The _____ logical operator works best when testing...Ch. 4 - The _____ logical operator works best when testing...Ch. 4 - A variable with _____ scope is only visible when...Ch. 4 - The expression that is tested by a switch...Ch. 4 - A program will fall through to the following case...Ch. 4 - Prob. 16RQECh. 4 - Write an if statement that assigns 100 to x when y...Ch. 4 - Write an if/else statement that assigns 0 to x...Ch. 4 - Write an if / else statement that prints Excellent...Ch. 4 - Write an if statement that sets the variable hours...Ch. 4 - Convert the following conditional expression into...Ch. 4 - Convert the following if/else if statement into a...Ch. 4 - Assume the variables x = 5, y = 6, and z = 8....Ch. 4 - Assume the variables x = 5, y = 6, and z = 8....Ch. 4 - Write a C++ statement that prints the message The...Ch. 4 - Prob. 26RQECh. 4 - Write a C++ statement that prints the message The...Ch. 4 - Prob. 28RQECh. 4 - Using the following chart, write a C++ statement...Ch. 4 - Write one or more C++ statements that assign the...Ch. 4 - The following statement should determine if x is...Ch. 4 - The following statement should determine if count...Ch. 4 - The following statement should determine if count...Ch. 4 - The following statement should determine if x has...Ch. 4 - Each of the following program segments has errors....Ch. 4 - Sometimes either a switch statement or an if /else...Ch. 4 - Minimum / Maximum Write a program that asks the...Ch. 4 - Roman Numeral Converter Write a program that asks...Ch. 4 - Magic Dates The date June 10, 1960, is special...Ch. 4 - Areas of Rectangles The area of a rectangle is the...Ch. 4 - Book Club Points An online book club awards points...Ch. 4 - Change for a Dollar Game Create a change -counting...Ch. 4 - Time Calculator Write a program that asks the user...Ch. 4 - Math Tutor Version 2 This is a modification of the...Ch. 4 - Software Sales A software company sells a package...Ch. 4 - Bank Charges A bank charges 15 per month plus the...Ch. 4 - Prob. 11PCCh. 4 - Color Mixer The colors red, blue, and yellow are...Ch. 4 - Running the Race Write a program that asks for the...Ch. 4 - Personal Best Write a program that asks for the...Ch. 4 - February Days The month of February normally has...Ch. 4 - Body Mass Index Write a program that calculates...Ch. 4 - Fat Gram Calculator Write a program that asks for...Ch. 4 - Prob. 18PCCh. 4 - The Speed of Sound in Gases When traveling through...Ch. 4 - Spectral Analysis If a scientist knows the...Ch. 4 - Freezing and Boiling Points The following table...Ch. 4 - Mobile Service Provider A mobile phone service has...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Modify the program in Figure 8.18 so that the following two conditions are met: 1. Each child terminates abnorm...
Computer Systems: A Programmer's Perspective (3rd Edition)
The following pseudocode statement calls an objects method. What is the name of the method? What is the name of...
Starting Out with Programming Logic and Design (4th Edition)
Explain which is more like a stencil—a class template or a class-template specialization?
C How to Program (8th Edition)
Explain the term cursor.
Database Concepts (7th Edition)
Many contemporary languages allow two kinds of comments: one in which delimiters are used on both ends (multipl...
Concepts of Programming Languages (11th Edition)
There are three seating categories at a high school athletic stadium. For a baseball game, Class A seats cost 1...
Starting Out With Visual Basic (8th 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
- 1. Write a code using the if/else condition where user enters an integer value for percentage. You are required to display the grade of student based on following ranges, If percentage is above 80, assign grade A and display it b. If percentage is above 70, assign grade B and display it If percentage is above 60, assign grade C and display it d. For all other values, display a message that "The entered percentage is not within required range". a. C.arrow_forwardin C#arrow_forwardChapter 5 Selection Statement ASSIGNMENT3 1. Using the switch statement, write a program that converts a numerical grade into a letter grade: Enter numerical grade: 84 Letter grade: B Use the following grading scale: A = 90~100, B = 80~89, C = 70~79, D = 60~69, F = 0~59. Print an error message if the grade is larger than 100 or less than 0. Hint: Break the grade into two digits, then use a switch statement to test the ten’s digit. 1. Write your program here: #include <stdio.h> int main(){ …… return 0; } 2. Write a program that asks the user for a two-digit number, then prints the English word for the number: Enter a two-digit number: 45 You entered the number forty-five. Hint: Break the number into two digits. Use one switch statement to print the word for the First digit (“twenty” “thirty" and so forth). Use a second switch statement to print the word for the second digit. Don’t forget that the numbers between 11 and 19 require special treatment. 2. Write your…arrow_forward
- Q1: b- Write a program that uses a switch statement to determine if the number is odd or even for the range of numbers from 1 to 10.arrow_forwardC++arrow_forwardIf no case label matches in switch statement, then the only statements executed are those following: O First case default O Last case O breakarrow_forward
- Ron bought several acres of farm to grow and sell vegetables. Suppose that Ron wants to grow a maximum of two types of vegetables. Write a program that prompts Ron or the user to do the following: Enter the total farm area in acres. The number of vegetables (one or two) that the user wants to grow. If the user wants to grow trwo types of vegetables, then specify the portion,as a percentage, of the farm land used for each type of vegetable. Enter the seed cost, plantation cose, fertilizing cost, labor cost, for each acre. Enter vegetable selling price per acre. Output the total revenue. Output the profit/loss.arrow_forward(Mathematical functions) Write a program that calculates and displays values for y when y=xz/(xz) Your program should calculate y for values of x ranging between 1 and 5 and values of z ranging between 2 and 6. The x variable should control the outer loop and be incremented in steps of 1, and z should be incremented in steps of 1. Your program should also display the message Function Undefined when the x and z values are equal.arrow_forward(Misc. application) a. Write a program to reverse the digits of a positive integer number. For example, if the number 8735 is entered, the number displayed should be 5378. (Hint: Use a do statement and continuously strip off and display the number’s units digit. If the variable numinitially contains the number entered, the units digit is obtained as (num % 10). After a units digit is displayed, dividing the number by 10 sets up the number for the next iteration. Therefore, (873510)is5and(8735/10)is873. The do statement should continue as long as the remaining number is not 0.) b. Run the program written in Exercise 3a and verify the program by using appropriate test data.arrow_forward
- Program IV: The Tuition Part Write a program that prompts the user to enter the number of courses taken by a student. The program reads the code and the credit of each course, uses the switch statement to calculate, and print the tuition fees the student has to pay. Each course code includes 7 digits; the leftmost two digits indicates the course college. The tuition is calculated by multiplying college fees by the number of credits. The following table indicates the fee of every college: College code Fee per 1 credit 11 700 12 950 13 600 14 1200 15 800 The program should check if the code is a valid code. See given sample of input / output: Sample input / output: Enter the number of courses: 3 Enter the code and credit of course number 1: 1310362 3 Enter the code and credit of course number 2: 1850116 4 Enter the code and credit of course number 2: 1550116 4 Enter the code and credit of course number 3: 1030423 2 Enter the code and credit of course number 3: 2030423 2 Enter the code…arrow_forwardProgram IV: The Tuition Part Write a program that prompts the user to enter the number of courses taken by a student. The program reads the code and the credit of each course, uses the switch statement to calculate, and print the tuition fees the student has to pay. Each course code includes7 digits the leftmost two digits indicates the course college. The tuition is calculated by multiplying college Tees by the number of credits. The following table indicates the fee of every college: College code Fee per 1 credit 11 700 12 950 13 600 14 1200 15 800 The program should check if the code is a valid code. See given sample of input / output: Sample input / output:arrow_forwardIn C language The if...else statement executes two different codes depending .upon whether the test expression is true or false False True * In C language is invalid identifier su_b O intarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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