Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2.4, Problem 23STE
Write an if-else statement that outputs the word Passed provided the value of the variable exam is greater than or equal to 60 and the value of the variable programs_done is greater than or equal to 10. Otherwise, the if-else statement outputs the word Failed. The variables exam and programs_done are both 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 to enter a person's age. The
Problem 2: Age Classifier
program should display a message indicating whether the person is an infant, a child, a teenager, or an
adult. These are the guidelines:
If the person is 1 year or less, he or she is an infant
If the person is older than 1 year, but younger than 13 years, he or she is a child.
If the person is at least 13 years old, but less than 20 years old, he or she is a teenager.
If the person is at least 20 years old, he or she is an adult.
C-Program for blood pressure.
The program (screenshot below) compares the systolic & diastolic measurements to output whether the blood is (low, ideal, pre-high, or high)
The code I wrote is able to successfully determine the blood pressure type as long as it lies within the same range.
However, if it goes outside that range it prints an error.
FOR EXAMPLE**** PLEASE READ*** If the user inputs their systolic variable as 100 and their systolic as 90, it will print an error.
If the systolic & diastolic measurements are vastly different the program prints an error, if you could help resolve this issue it would be greatly appreciated.
Please answer in matlab code.
Chapter 2 Solutions
Problem Solving with C++ (10th 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...Ch. 2 - Prob. 16PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
(Sort students on grades) Rewrite Listing 8.2, GradeExam.java, to display the students in increasing order of t...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
The Upper West View Yacht club sponsors sailboat races every weekend for its fleet of SuperGee sailboats, and w...
Starting Out With Visual Basic (7th Edition)
For each of the following situations, tell which type of loop (while, do-while, or for) would work best: a. Sum...
Absolute Java (6th Edition)
Consider the adage Never ask a question for which you do not want the answer. a. Is following that adage ethica...
Experiencing MIS
What is the biggest difference between a parameter of a primitive type and a parameter of a class type?
Java: An Introduction to Problem Solving and Programming (8th Edition)
Describe some design trade-offs between efficiency and safety in some language you know.
Concepts of Programming Languages (11th 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
- 4. During each summer, John and Jessica grow vegetables in their backyard and buy seeds and fertilizer from a local nursery. The nursery carries different types of vegetable fertilizers in various bag sizes. When buying a particular fertilizer, they want to know the price of the fertilizer per pound and the cost of fertilizing per square foot. The following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost of the bag, and the area, in square feet, that can be covered by the bag. The program should output the desired result. However, the program contains logic errors. Find and correct the logic errors so that the program works properly. // Logic errors. #include #include using namespace std; int main() { double costs double area; double bagsize; cout > bagsize; cout > cost; cout > area; cout << endl; cout << "The cost of the fertilizer per pound is: $" << bagsize / cost << endl; cout << "The cost of fertilizing per square foot is: $" << area / cost << endl; return 0; }arrow_forwardComplete the following program When a machine reads blood pressure from a human body it displays two numbers they are called Systolic and Diastolic pressures. The program will take systolic and diastolic reading as input from the user and displays a message whether the person's blood pressure is "Normal" or "Elevated" or "High Blood Pressure". Program consists of two functions as follows. vold input .: This function is with two pass by reference parameters, and it reads input from the user. string process( .): It receives two numbers(systolic and diastolic) and then it determines and returns a category according to the table below. Diastolic and 60 to 80 and 80 to 90 Category Systolic Normal 80 to 120 Elevated 120 to 139 High blood equal and pressure above 140 above 90 orarrow_forwardREQUIREMENT USE A SWITCH STATEMENT SELECTION STRUCTURE Write a logically correct Java switch statement that performs the following task: Takes input for an int range 1 through 12, then outputs the month. Example 1 outputs "January", 2 outputs "February", etc....if a non-valid int value is encountered, we output "not a valid month".arrow_forward
- using c++ Write a program that computes and displays the charges for a patient's hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient, the following data should be entered: The number of days spent in the hospital The daily rate Hospital medication charges Charges for hospital services (lab test, etc.) The program should ask for the following data if the patient was an out-patient: Charges for the hospital services (lab test, etc.) Hospital medication charges The program should use two functions to calculate the total charges. One of the functions should accept arguments for the in-patient data, while the other function accepts arguments for out-patient information. Both functions should return the total charges.arrow_forwardThe following statement should determine if x is not greater than 20. What is wrong with it?arrow_forwardComplete the following program When a machine reads blood pressure from a human body it displays two numbers they are called Systolicand Diastolic pressures. The program will take systolic and diastolic reading as input from the user and displays a message whether the person's blood pressure is "Normal" or "Elevated" or "High Blood Pressure". Program consists of two functions as follows. void input( .): This function is with two pass by reference parameters, and it reads input from the user. string process..): It receives two numbers(systolic and diastolic) and then it determines and returns a category according to the table below. Systolic |80 to 120 | 120 to 139 High blood equal and above 140 Diastolic Category Normal and 60 to 80 Elevated and 80 to 90 pressure above 90 or main () program is given below and you are asked to write the function definitions in the space provided below. #include #include using namespace std; void input(int &, int &); string process(int, int); int main()…arrow_forward
- Complete the following program When a machine reads blood pressure from a human body it displays two numbers they are called Systolic and Diastolic pressures. The program will take systolic and diastolic reading as input from the user and displays a message whether the person's plood pressure is "Normal" or "Elevated" or "High Blood Pressure". Program consists of two functions as follows. vold input( .):This function is with two pass by reference parameters, and it reads input from the user. itring process.): It receives two numbers(systolic and diastolic) and then it determines and returns a category Iccording to the table below. Systolic 80 to 120 Diastolic and 60 to 80 80 to 90 Category Normal Elevated 120 to 139 and equal and above 140 High blood pressure above 90 or main () program is given below and you are asked to write the function definitions in the space provided below. #include #include using namespace std; void input(int &, int &); string process(int, int): int main() int…arrow_forwardSwitch Statement Problem 5. Electric Bill: Write a program that will calculate and show bills of the Manila Electric Company. The rates vary depending on whether the use is residential (R), commercial( C), or industrial (1). Any other code should be treated as an error. The program should accept the subscriber ID, Subscriber Name, his total electrical consumption in a month, and the code of the consumer type. The rates are computed as follows: R: 50 plus .50 per kwh used C: 100 for the first 1000 kwh and 0.45 for each additional kwh I: 180 for the first 1000 kwh and 0.75 for each additional kwharrow_forwardIn Python Text-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. The selection variable must be sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. Add an if statement in the choice() function to make the correct selection.arrow_forward
- Q16/ Write a program that accepts a user-entered number and calculates the square root. 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. HINT: using functions.arrow_forwardThe following statements allows conditional execution is: if statement False Truearrow_forwardC++ using multiple functions if possible. Write a program to score the paper-rock-scissor game. For this game, the user will play against the computer, so have the computer selection use Random. The user types in either P, R, or S, (or 1, 2, or 3, depending on how you set it up). Make sure to include error checking to help the user enter the correct data selections. The program then announces the winner as well as the basis for determining the winner: "Paper covers rock", "Rock breaks scissors", "Scissors cut paper", or "It was a tie". Be sure to allow the users to use lowercase as well as uppercase letters. Your program should include a loop that lets the user play again until the user says she or he is done.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,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
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