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, Problem 2PC
Roman Numeral Converter
Write a
Input Validation: Decide how the program should handle an input that is less than 1 or greater than 10.
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.
language JAVA
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.
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
Can you reference an instance variable by name within the definition of a non-static method without using a cla...
Java: An Introduction to Problem Solving and Programming (7th Edition)
T F All private members of a class must be declared together.
Starting Out with C++ from Control Structures to Objects (9th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Consider a Java class that you could use to get an acceptable integer value from the user. An object of this cl...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Consider the adage Never ask a question for which you do not want the answer. a. Is following that adage ethica...
Experiencing MIS
John Programmer argues that the ability to declare constants within a program is not necessary because variable...
Computer Science: An Overview (12th 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
- (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_forwardSubmit your answer in the comment section. Days of the Week Write a program that asks the user for a number in the range of 1 through 7. The program should display the corresponding day of the week, where 1- Monday. 2- Tuesday and so forth. If the user types in a 6 then "Saturday should be printed on the screen. For help with Input statements see: Input Function • The program should print an error message if the user enters a number that is outside the range of 1 through 7. For help with If statements and conditions see the following pages: If-Eke Statements and Operators • Name the source code file yourName HW4_1.py. • Test and run the program. Capture the output console and save it as an image file named yourName Hw3 output4 1jpg. • Submit the py and the image files through Canvas.arrow_forwardA Charge Account Statement Write a program to prepare the monthly charge account statement for a customer of CS CARD International, a credit card company. The program should take as input the previous balance on the account and the total amount of additional charges during the month. The program should then compute the interest for the month, the total new balance (the previous balance plus additional charges plus interest), and the minimum payment due. Assume the interest is 0 if the previous balance was 0 but if the previous balance was greater than 0 the interest is 2% of the total owed (previous balance plus additional charges). Assume the minimum payment is as follows: new balance for a new balance less than $50 $50.00 for a new balance between $50 and $300 (inclusive) 20% of the new balance for a new balance over $300 So if the new balance is $38.00 then the person must pay the whole $38.00; if the balance is $128 then the person must pay $50; if the balance is $350 the minimum…arrow_forward
- C++ Visual Studio Modify the following program so it displays a menu allowing the user to select an addition, subtraction, multiplication, or division problem. The final selection on the menu should let the user quit the program. After the user has finished the math problem, the program should display the menu again. This process is repeated until the user chooses to quit the program. Input Validation: If the user selects an item not on the menu, display an error message and display the menu again. Code: #include <iostream>#include <cstdlib>#include <ctime>#include <conio.h> using namespace std; int main() {srand(static_cast<unsigned int>(time(nullptr))); while (true) {// Generate two random numbers.int num1 = rand() % 1000;int num2 = rand() % 1000; // Display the problem.cout << "Solve the following math problem:" << endl;cout << num1 << " + " << num2 << endl; // Wait for user input to reveal the answer.cout <<…arrow_forwardSoftware Sales A software company sells a package that retails for $99. Quantity discounts are given below: Quantity Discount 10–19 20% 20–49 30% 50–99 40% 100 or more 50% Design a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.arrow_forward/*random number guessing game with while loopscreate a program (or adapt the guessing game program that's posted in moodlea couple of weeks ago) that asks the user to guess a random number between one and sixteen,and compares their guess with the computer's number.save this program as guessLoops.cppThe program should display one of four messages:if your guess is higher than the computer's number: "Your guess is too high."if your guess is lower than the computer's number: "Your guess is too low."if your guess is the same as the computer's number: "That is correct!"if your guess is less than one or greater than sixteen: "Invalid guess."If it's the last one, invalid guess, prompt the user, by using a loop, to guess again.If your guess is too high or too low, ask the user if they'd like to guess again (if theanswer is 'y' for yes, repeat the statements that asks for a guess.Then, repeat statement on line #6-#9 above.If the answer is 'n' for no (meaning the user doesn't want to guess…arrow_forward
- Lottery number in pythonarrow_forwardRemaining Time: 54 minutes, 49 seconds. * Question Completion Status: QUESTION 19 Write a Java program that prompts the user to enter the School Grade Level of a student and then calculate their discount amount in the regular fees structure offered during this pandemic situation. By using the below table, calculate their discount amount from the amount of the regular fee and then print the discount amount in OMR by using the appropriate selection structure. (Assume the user is entering a maximum Grade level is 12) discount amount = Regular Fees * percentage of discount rate School Grade Level Regular Fees in OMR Discount Rate >9 and 6 and 3 and 0 and <=3 30.500 5% otherwise 20.400 No discount T T T Arial 3 (12pt) v T -E E- 只i ン Click Save and Submit to save and submit. Click Save All Answers to save all answers. Save All Answers TOSHIBA F5 F6 F7 F8 F9 F10 F11 F12 INS SCNULL LOCK AD & 67 7 V 8A9 4 0arrow_forwardC Languagearrow_forward
- Python Programming onlyarrow_forward1) quadratic.py Write a program that prompts the user to input the three coefficients a, b, and c of a quadratic equation az²+bx+c= 0. The program should display the solutions of this equation, in the following manner: 1. If the equation has one solution, display ONE SOLUTION:, followed by the solution, displayed with 4 digits printed out after the decimal place. 2. If the equation has two real solutions, display TWO REAL SOLUTIONS:, followed by the two solutions, each displayed with 4 digits printed out after the decimal place. 3. If the equation has solutions that are not real numbers, display COMPLEX SOLUTIONS:, followed by two solutions displayed in the form a + bi, where each a and b should be displayed with 4 digits printed out after the decimal place. For example, a run might look like Enter x 2 coefficient: 1 Enter x 1 coefficient: -2 Enter x 0 coefficient: 1 ONE SOLUTION: x= 1.0000 or Enter x^2 coefficient: 3 Enter x 1 coefficient: 5 Enter x 0 coefficient: 1 TWO REAL…arrow_forwardProblem 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 rightarrow_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 LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
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
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
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