STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
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…
Write 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.
Question: 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: 2
Chapter 4 Solutions
STARTING OUT WITH C++ MPL
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_forward35. Evaluate: 1+6==7 || 3+2==1. Write T for true and F for false ( ||-or)arrow_forwardif (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_forward
- Assuming the following code: int x = myfunction1 (); /* arbitrary value */ myfunction2 (); /* arbitrary value */ int y = unsigned ux = x; unsigned uy = y; The following statement always evaluates to 1 (True or False): x > 0 || -x >= 0 True Falsearrow_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_forward22. What is the value of x after the following statements are executed? int x = 5; switch(x) { case 5: x += 2; case 6: x++; break; default: x *= 2; break; }arrow_forward
- a*a; a*a*a; d = (a); fprintf('%4u square equals %4u \r', a, b) fprintf('%4u cube equals %4u \r', a, c) fprintf('The square root of %2u is %6.4f \r', a, d) b C =arrow_forwardCondtionalsdef print_func(x, y): if y >= 5: print(‘A’) print(‘B’) if x > 20: print(‘C’) if y > 10: print(‘D’) if y > 5: print(‘E’)elif x > 10 and y <= 5: print(‘F’)else: print(‘G’)What gets output for the following arguments to print_func?x: 20 y: 5 x: 30 y: 20 x: 20 y:10 so I'm trying to input this sstuff into pycharm and run it with doign some self.assert tests to run it but im runnign across multiple problems. what do. How do I go about this?arrow_forwardUntitled Section This is a segment of program, when it executed with multiple values for n and s the program displays the value of f, choose which output of f values are wrong answers cin>>x>>y; if (x>1) &&(y<5) {f=x+y*9; else f-x-y-11; } cout<arrow_forwardQ3: Write a program in which user is asked to enter two integers (divisor and dividend) and computes the quotient and remainder. To compute quotient and remainder, both divisor and dividend should be integers.arrow_forwardQ3/A- Estimate the result when you execute the following code by using Qbasic programming For m take the following values 100,90,80,70,60,50,40,30,20,10,30: Input "enter student mark"; m If m - 100 Then Print "ful mark" Elself m >= 90 Then Print "accelent" Elself m> 80 Then Print "very good" Elself m>- 70 Then Print "accepted" Print "fail" Else End Ifarrow_forwardIf you have the following statements: int a=2, b=3, c=4; double z=4.5, w=6.7; const float f=8.9; The output of the statement: cout<<((a * z) / b); О 4.0 3.0 О 3.5arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_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