Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2.4, Problem 21STE
Write an if-else statement that outputs the word High if the value of the variable score is greater than 100 and Low if the value of score is at most 100. The variable score is of type int.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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-Else 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_1.jpg.
Submit the .py and the image files through Canvas.
Write an if-else statement that outputs the word “Passed” provided thevalue of the variable exam is greater than or equal to 60 and also the valueof the variable programsDone is greater than or equal to 10. Otherwise, theif-else statement should output the word “Failed”. The variables exam andprogramsDone are both of type int.
Write an if-else statement that outputs the word “Emergency” provided the valueof the variable pressure is greater than 100 or the value of the variable temperatureis greater than or equal to 212. Otherwise, the if-else statement should outputthe word “OK”. The variables pressure and temperature are both of type int.
Chapter 2 Solutions
Problem Solving with C++ (9th Edition)
Ch. 2.1 - Give the declaration for two variables called feet...Ch. 2.1 - Give the declaration for two variables called...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Give a C++ statement that will increase the value...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Prob. 6STECh. 2.1 - Prob. 7STECh. 2.2 - Give an output statement that will produce the...Ch. 2.2 - Give an input statement that will fill the...Ch. 2.2 - Prob. 10STE
Ch. 2.2 - Write a complete C++ program that writes the...Ch. 2.2 - Write a complete C++ program that reads in two...Ch. 2.2 - Prob. 13STECh. 2.2 - Write a short program that declares and...Ch. 2.3 - Convert each of the following mathematical...Ch. 2.3 - Prob. 16STECh. 2.3 - What is the output of the following program lines...Ch. 2.3 - Write a complete C++ program that reads two whole...Ch. 2.3 - Given the following fragment that purports to...Ch. 2.3 - What is the output of the following program lines...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Suppose savings and expenses are variables of type...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Consider a quadratic expression, say x2 x 2...Ch. 2.4 - Consider the quadratic expression x2 4x + 3...Ch. 2.4 - What is the output of the following cout...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What output would be produced in the previous...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the most important difference between a...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - Write a complete C++ program that outputs the...Ch. 2.5 - The following if-else statement will compile and...Ch. 2.5 - Prob. 36STECh. 2.5 - Write a complete C++ program that asks the user...Ch. 2 - A metric ton is 35,273.92 ounces. Write a program...Ch. 2 - The Babylonian algorithm to compute the square...Ch. 2 - Many treadmills output the speed of the treadmill...Ch. 2 - Write a program that plays the game of Mad Lib....Ch. 2 - The following is a short program that computes the...Ch. 2 - A government research lab has concluded that an...Ch. 2 - Workers at a particular company have won a 7.6%...Ch. 2 - Modify your program from Programming Project 2 so...Ch. 2 - Negotiating a consumer loan is not always...Ch. 2 - Write a program that determines whether a meeting...Ch. 2 - Prob. 6PPCh. 2 - It is difficult to make a budget that spans...Ch. 2 - You have just purchased a stereo system that cost...Ch. 2 - Write a program that reads in ten whole numbers...Ch. 2 - Modify your program from Programming Project 9 so...Ch. 2 - Sound travels through air as a result of...Ch. 2 - Prob. 12PPCh. 2 - The HarrisBenedict equation estimates the number...Ch. 2 - Write a program that calculates the total grade...Ch. 2 - It is important to consider the effect of thermal...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Define the term database.
Database Concepts (8th Edition)
Look at the following code: structure Rectangle { int length; int width; }; Rectangle r = nullptr Write stateme...
Starting Out with C++ from Control Structures to Objects (9th Edition)
Given the definition of a d structure as defined in this chapter, write a function called d that takes a pointe...
Programming in C
How do you identify the potential classes in a problem domain description?
Starting Out with C++: Early Objects
Consider the adage Never ask a question for which you do not want the answer. a. Is following that adage ethica...
Experiencing MIS
To open a file for reading, you use the following classes. a. File and Writer b. File and Output c. File and In...
Starting Out with Java: Early 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
- Scenario: You have been tasked with writing a program that reads the total price of the items brought into the hypermarket and calculates the value-added tax applied to the purchase based on the following rules. If the total price is between 0 and 100, no tax will be applied. Otherwise, if the total price is between 101 and 200, the program will apply a tax of 2% of the total price. Furthermore, if the total price is between 200 and 300, the tax is 5% of the total price. Finally, if the total price is greater than 300, the tax is 10% of the total price. hellp ):arrow_forwardThe date June 10, 1960, is special because when we write it in the following format, the month times the day equals the year: 6/10/60 Write a program that ask the user to enter a month in numeric format, a day and a two-digit year. The program should then determine whether the month times the day is equal to the year. If so, it should display a message saying the date is Magic. Otherwise, it should display a message saying the date is not Magic. Output should look as shown below. Create test data and place in a file. Name the code file Last Name + First Initial + "-MagicDates.s", for example "SmithJ- MagicDates.s". Name the test data file in a similar manner. Upload the program and test data files to the Dropbox. 6/10/60 is Magic! 6/10/70 is not Magic. 2/11/22 is Magic!arrow_forwardPlease answer in matlab code.arrow_forward
- 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.arrow_forward1. Write a program that prompts the user to enter an integer between 0 and 6 and prints thie day name of the week (Sunday is 0, Monday is 1,..., and Saturday is 6). 2. Write a program that prompts the user to enter an integer and tests if it is divisible by 5 and 3, or if its divisible by 5 or 3 or if its divisible by 5 or 3 but not both.arrow_forward5-WRITE A PROGRAM THAT CALCULATESA STUDENT'S AVERAGE IF IT IS LESS THAN 50, SPECIFYING THE STUDENT'S NAME AND AVERAGE IN RED 6-WRITE A PROGRAM THAT CHECKS THE VALUE OF A VARIABLE, WHETHER THE NUMBER ONE IS PRINTED ON SUNDAY, AND IF THE NUMBER TWO IS PRINTED ON MONDAY, AND IF THE NUMBER THREE IS PRINTED ON TUESDAY, ETC., UNTIL WE REACH FRIDAY, IT WILL PRINT A ZERO. 7-A COMPUTER COMPANY SELLS 200 PIECES OF MOTHERBOARD PER DAY, HOW MUCH DO YOU SELL PER MONTH, KNOWING THAT FRIDAY IS THE COMPANY'S HOLIDAY, KNOWING THAT THE COMPANY CONTAINS 150 EMPLOYEES AND THE SALARY OF EACH EMPLOYEE IS 2000 DOLLARS PER MONTHarrow_forward
- 1- If money is left in a particular bank for more than 5 years, the bank pays interest at a rate of 4.5% of the money; otherwise, the interest rate is 3.0% of the money. Write a program to accept the number of years in the variable numYears and money in the variable money then display the correct interest rate, depending on the value input into numYears 2- Write a program that accepts a user-entered number and calculates the square. Before calculating, check that the number is negative, and isn't zero. If either condition occurs, display a message stating that the operation can't be calculated. 3- Write a program which accept a number of 2 digits and check if ones digit is greater than the tens digit print the number in reverse order, if each of the ones digit and the tens digit greater than 5 print the average of them (ones and tens), otherwise print the message( NOT valid ). 4- Write C++ program to accept a number num (with any number of digits). Then, if the number of digits equal…arrow_forwardPLEASE CODE THIS IN VISUAL CODE & MAKE SURE IT RUNSarrow_forwardThe BITI Students Club is offering a new travelling package or membership. People can choose either one of three packages : a) business, b) family or c)single package. Each packages have different prices for monthly subscription. A business package is RM40, a family package is RM20 and single package is RM30. People can choose any package and duration-in-month for subscription. The program will calculate and display the total of payment. The program can be repeated as long as the option to exit is not selected. Any invalid input will result in an error message to retry. Create a program that have at least three user defined functions. Three of the functions are having the return type void and calculating the total of each packages. The display is done in separate function.arrow_forward
- BAU Write a program that inputs three different integers from the keyboard, then prints the sum, the average, the product, the smallest and the largest of these numbers. Use only the single-selection form of the if statement you learned in this chapter. The screen dialogue should appear as follows: 2 Input three different integers: 13 27 14 Sum is 54 Average is 18 Product is 4914 Smallest is 13 Largest is 27arrow_forwardAn argument is expressed in English below. Sara is not excited. If Sara is not excited, then Sara will go to the party. Sara is sleepy. 4 : Sara will go to the party and Sara is sleepy. Variable names are assigned to each English phrase as follows: • q: Sara is excited •r: Sara will go to the party • : Sara is sleepy What is the form of the argument? Pick Pick v .: Pick 2 Check Nextarrow_forwardQuestion 1 Write a program which takes the input from the user of time and distance and calculate the speed Where speed = distance / time If speed is between 40 -80, Print the message "You are Safe Driver" If speed is between 81 – 100, Print the message "Drive Carefully" If speed is more than 101, Print the message "Risky Driving" Otherwise print "Try again".arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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