C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 4, Problem 4.20E
(Validating User Input) The examination-results
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
( MindTap - Cenage )Example 5-6 implements the Number Guessing Game program. If the guessed number is not correct, the program outputs a message indicating whether the guess is low or high.
Modify the program as follows: Suppose that the variables num and guess are as declared in Example 5-6 and diff is an int variable. Let diff = the absolute value of (num - guess).
If diff is 0, then guess is correct and the program outputs a message indicating that the user guessed the correct number.
Suppose diff is not 0. Then the program outputs the message as follows:
If diff is greater than or equal to 50, the program outputs the message indicating that the guess is very high (if guess is greater than num) or very low (if guess is less than num).
If diff is greater than or equal to 30 and less than 50, the program outputs the message indicating that the guess is high (if guess is greater than num) or low (if guess is less than num).
If diff is greater than or equal to 15 and less than 30, the…
(Sort three integers) Write a program that prompts the user to enter THREE integers and
display the integers in decreasing order.
Prepare your problem analysis and algorithm (pseudocode or flowchart) to plan your
solution.
(Algebra: solve 2 * 2 linear equations) A linear equation can be solved using Cramer’s rule given in Programming Exercise 1.13. Write a program that prompts the user to enter a, b, c, d, e, and f and displays the result. If ad - bc is 0, report that “The equation has no solution.”
Chapter 4 Solutions
C++ How to Program (10th Edition)
Ch. 4 - (Correct the Code Errors) Identity and correct the...Ch. 4 - (What Does this Program Do?) What does the...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - (Find the largest) The process of finding the...Ch. 4 - (Tabular Output) Write a C++ program that uses a...Ch. 4 - (Find the Two Largest Numbers) Using an approach...Ch. 4 - (Validating User Input) The examination-results...
Ch. 4 - (What Does this Program Do?) What does the...Ch. 4 - (What Does this Program Do?) What does the...Ch. 4 - (Dangling-else Problem)C++ compliers always...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - (Square of Asterisks) Write a program that reads...Ch. 4 - (Palindromes) A palindrome is a number or a text...Ch. 4 - (Printing the Decimal Equivalent of a Binary...Ch. 4 - (Checkerboard Pattern of Asterisks) W rite a...Ch. 4 - (Multiples of 2 with an Infinite Loop) write a...Ch. 4 - (Calculating a Circle’s Diameter, circumference...Ch. 4 - What’s wrong with the following statement? Provide...Ch. 4 - (Sides of a Triangle) Write a program that reads...Ch. 4 - (Sides of a Right Triangle) Write a program that...Ch. 4 - (Factorial) The factorial of a nonnegative integer...Ch. 4 - (Modified Account Class) Modify class Account...Ch. 4 - (Enforcing Privacy with Cryptography) The...Ch. 4 - (World Population Growth) World population has...
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
- (Algebra: solve 2 x 2 linear equations) You can use Cramer's rule to solve the following 2 x 2 system of linear equation: ax + by = e ed – bf af- ec ad - bc cx + dy = f ad – bc y = Write a program that prompts the user to enter a and f and display the result. If ad - bc is 0 b, c, d , e, , report that The equation has no solution.arrow_forward(Python matplotlib or seaborn) CPU Usage We have the hourly average CPU usage for a worker's computer over the course of a week. Each row of data represents a day of the week starting with Monday. Each column of data is an hour in the day starting with 0 being midnight. Create a chart that shows the CPU usage over the week. You should be able to answer the following questions using the chart: When does the worker typically take lunch? Did the worker do work on the weekend? On which weekday did the worker start working on their computer at the latest hour? cpu_usage = [ [2, 2, 4, 2, 4, 1, 1, 4, 4, 12, 22, 23, 45, 9, 33, 56, 23, 40, 21, 6, 6, 2, 2, 3], # Monday [1, 2, 3, 2, 3, 2, 3, 2, 7, 22, 45, 44, 33, 9, 23, 19, 33, 56, 12, 2, 3, 1, 2, 2], # Tuesday [2, 3, 1, 2, 4, 4, 2, 2, 1, 2, 5, 31, 54, 7, 6, 34, 68, 34, 49, 6, 6, 2, 2, 3], # Wednesday [1, 2, 3, 2, 4, 1, 2, 4, 1, 17, 24, 18, 41, 3, 44, 42, 12, 36, 41, 2, 2, 4, 2, 4], # Thursday [4, 1, 2, 2, 3, 2, 5, 1, 2, 12, 33, 27, 43, 8,…arrow_forward(Display the day and remaining hours) Write a program that prompts the user to enter the day number of a week and hours passed, and displays the day and remain- ing hours. For example, if the user entered day number 1 and hours passed 20, the program should display Today is Sunday and Remaining Hours: 4. If the user entered day number 7 and hours passed 2, the program should display Today is Saturday and Remaining Hours 22.arrow_forward
- 5. (Algebra: solve 2 X 2 linear equations) You can use Cramer's rule to solve the following 2 X 2 system of linear equation: ax + by = e cx + dy = f ● x = ed - bf bc ad y = af - ec ad bc - Write a program that prompts the user to enter a, b, c, d, e, and f and display the result. If ad- bc is 0, report that The equation has no solution. Enter a, b, c, d, e, f: 9.0, 4.0, 3.0, -5.0, -6.0, -21.0 Enter x is -2.0 and y is 3.0 Enter a, b, c, d, e, f: 1.0, 2.0, 2.0, 4.0, 4.0, 5.0 Enter The equation has no solutionarrow_forward(True/False): It is possible to define a procedure inside an existing procedurearrow_forward(Count the letters in a string) Write a function that counts the number of letters in a string using the following header: def countLetters(s) : Write a test program that prompts the user to enter a string and displays the number of letters in the string. the answer should be in python.arrow_forward
- (Rounding Numbers) Function floor can be used to round a number to a specific decimal place. The statementy = floor(x * 10 + 0.5) / 10;rounds x to the tenths position (the first position to the right of the decimal point). The statementy = floor(x * 100 + 0.5) / 100;rounds x to the hundredths position (the second position to the right of the decimal point). Write a program that defines fourfunctions to round a number x in various ways:A. roundToInteger(number)B. roundToTenths(number)C. roundToHundredths(number)D. roundToThousandths(number)For each value read, your program should print the original value, the number rounded to the nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth and the number rounded to the nearest thousandth.arrow_forward(Financials: currency exchange) Write a program that prompts the user to enter the exchange rate from currency in U.S. dollars to Rupees PKR. Prompt the user to enter 0 to convert from U.S. dollars to Rupees PKR and 1 to convert from Rupees PKR and U.S. dollars. Prompt the user to enter the amount in U.S. dollars or Rupees PKR to convert it to Rupees PKR or U.S. dollars, respectively. Use c++ program.arrow_forward(Factorials) Factorials are used frequently in probability problems. The factorial of a positive integer n (written n! and pronounced “n factorial”) is equal to the product of the positive integers from 1 to n. Write an application that calculates the factorials of 1 through 20. Use type long . Display the results in tabular format. What difficulty might prevent you from calculating the factorial of 100?arrow_forward
- (Temperature Conversions) Implement the following integer functions:a) Function toCelsius returns the Celsius equivalent of a Fahrenheit temperature.b) Function toFahrenheit returns the Fahrenheit equivalent of a Celsius temperature.c) Use these functions to write a program that prints charts showing the Fahrenheit equivalents of all Celsius temperatures from 0 to 100 degrees, and the Celsius equivalents ofall Fahrenheit temperatures from 32 to 212 degrees. Print the outputs in a tabular format that minimizes the number of lines of output while remaining readable.arrow_forward(Emirp) An emirp (prime spelled backward) is a nonpalindromic prime number whose reversal is also a prime. For example, 17 is a prime and 71 is a prime, so 17 and 71 are both emirps. Write a Java program that displays the first 100 emirps. Display 10 numbers per line with a spacing of 5; all numbers should be left-aligned.arrow_forward(C++ language)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License