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.3, Problem 4.15CP
True or false: The following if / else statements cause the same output to display.
A) if (x > y)
cout << "x is greater than y. \n";
else
cout << "x is not greater than y. \ n" ;
B) if (x <= y)
cout << "x is not greater than y. \n";
else
cout << "x is greater than y\n";
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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…
Program by using C #
C sharp
My student number :1910206534
i need the answer quickly
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
T F A member function of a derived class may not have the same name as a member function of the base class.
Starting Out with C++ from Control Structures to Objects (9th Edition)
(Multiples of 2 with an Infinite Loop) Write a program that keeps printing the multiples of the integer 2, name...
C How to Program (8th Edition)
Answer Problem 13 using SQL. PROBLEM 13 13. Using the commands SELECT, PROJECT, and JOIN, write a sequence of i...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
The following program will compile but it has run-time errors Find and fix the errors
Java: An Introduction to Problem Solving and Programming (8th Edition)
Does the following diagram depict multiple inheritance or a chain of inheritance?
Starting Out with C++ from Control Structures to Objects (8th Edition)
A file that contains a Flash animation uses the __________ file extension. a. .class b. .swf c. .mp3 d. .flash
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
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
- (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_forwardQ7-Write a program that simulates a simple calculator. It reads two integers and a character. If the character is a +, the sum is printed; if it is a -, the difference is printed; if it is a *, the product is printed; if it is a /, the quotient is printed; and if it is a %, the remainder is printed. (Use a switch statement.)arrow_forwardWrite aprogram using nestedif statements that perform the following test: If the variable employed is equal to 'Y' and if worklength is equal or greater than 5, then display the message "Your credit card application is accepted". However, if worklength is less than 5, then display the message "Please provide a guarantor". Otherwise, if the variable employed is equal to 'N', then display the message "Your credit card application is rejected". C.arrow_forward
- The monthly payment on a loan may be calculated by the following formula: N Rate * (1 + Rate)* * L/; Payment (1 + Rate)" - 1 Rate is the monthly interest rate, which is the annual interest rate divided by 12. (A 12 percent annual interest would be 1 percent monthly interest.) N is the number of payments and L is the amount of the loan. Write a program that asks for these values and displays a report similar to the following: $ 10000.00 Loan Amount: Monthly Interest Rate: Number of Payments: Monthly Payment: Amount Paid Back: 18 36 $ $ 11957.15 $ 1957.15 332.14 Interest Paid:arrow_forwardQuestion: Write program that asks the user to enter car information for 3 cars. The user will read the car plate number, driven mileage and number of months since last service. The program should display the message ‘Car is due for service’ if one of the following is true: The car drove more than 5000 KM The program should also count and display the number of cars due for service. Input/Output example: Enter car plate number: 600600 Enter the mileage and number of months since last service: 5230 Car is due for service Enter car plate number: 600666 Enter the mileage and number of months since last service: 5002 Car is due for service Enter car plate number: 600222 Enter the mileage and number of months since last service: 1500 The number of cars due is: 2arrow_forward35. Evaluate: 1+6==7 || 3+2==1. Write T for true and F for false ( ||-or)arrow_forward
- if (x y)Z =5*x*x + 3* x / y; else Z =y*y - == 3*x; truecout 20);{Cout>>i; A program to print only 20 integer number * true Falsearrow_forwardLIFE INSURANCE PREMIUM CALCULATOR Write a C program that calculates monthly, quarterly, half-yearly and yearly life insurance premium based on given sum assured. Monthly Premium Quarterly Premium Half Yearly Premium Yearly Premium sum assured / (years*12). sum assured / (years*4). = sum assured / (years 2). = sum assured / years. %3D %3D Output of program Enter your sum assured: 250000 Enter life insurance policy term (in years):5 Your Monthly Premium Your Quarterly Premium Your Half Yearly Premium: 25000.00 Your Yearly Premium : 4166.67 : 12500.00 : 50000.00arrow_forward3.Professor Mysterious uses a special formula to calculate the grade of his students. Write a program that repeatedly does the following: a. Prompt the user to enter the grade of the first test b. Prompt the user to enter the grade of the second test . Prompt the user to enter the grade of the third test. The program should then calculate and displays the student grade based on the following formula: grade-.25*testi+.61 test2+.14 test3 NOTE: Exit the program using sentinel or magic value. SAMPLE PROGRAM RUN Enter Test1 (0 to exit): 100 Enter Test2:90 Enter Test3:87 Grade: 92.08 Enter Test1 (0 to exit): 0 Thank you for using this program.arrow_forward
- Answer this question Write a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:BMI = weight × 703 / height2where weight is measured in pounds and height is measured in inches. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person’s weight is considered to be optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25, the person is considered to be overweightarrow_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_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
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ 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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher: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
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY