Concept explainers
What would be the output in Self-Test Exercise 9 if the Boolean expression (x > 10) were changed to (x > 100)?
9. What output will be produced by the following code, when embedded in a complete
int x = 200;
cout << “Start\n”;
if (x < 100)
cout << “First Output. \n”;
else if (x > 10)
cout << “Second Output. \n”;
else
cout << “Third Output. \n”;
cout << “End\n”;
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (8th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with C++: Early Objects
Starting Out With Visual Basic (7th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- Analyze the following code: int x = 0;if (x > 0) ;{System.out.println(x);} The code has syntax error. The code has run time error. The value of variable x is always printed because the print statement is not controlled by the if condition. Nothing is printed because x > 0 is false if x = 0.arrow_forwardComplete the if-else statement to output "Below 90" if the value of userInput is below 90. Otherwise, output "90 or more". Ex: If the input is 88, then the output is: Below 90 1 import java.util.Scanner; 3 public class Relational { 345678 9 10 11 12 13 14 FREEdd public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userInput; 15 16 } 17 } userInput = scnr.nextInt (); if (* Your code goes here */) { System.out.println("Below 90"); } else { } System.out.println("90 or more");arrow_forwardplz solve it asap ????????: Write a program for a game that consists of two players. The rule of the game is that player 1 inputs a random number from 1-100. Player 2 will input 5 numbers. If the summation of those numbers is equal to the number OR less than or greater than the number by 3 (+3 or -3), then player 2 wins. Otherwise, player 1 wins. Test Case 1 Input Player 1, enter a number: 50 Player 2, enter a number: 10 Player 2, enter a number: 10 Player 2, enter a number: 20 Player 2, enter a number: 5 Player 2, enter a number: 7 Output Player 2 wins Explanation: The summation of 10,10,20,5 and 7 is 52 which is greater than 50 by 2. According to the rule, player 2 wins. Test Case 2 Input Player 1, enter a number: 50 Player 2, enter a number: 10 Player 2, enter a number: 10 Player 2, enter a number: 20 Player 2, enter a number: 5 Player 2, enter a number: 1 Output Player 1 wins Explanation: The summation of 10,10,20,5 and 1 is 46 which is less than 50 and also doesn’t…arrow_forward
- javaarrow_forward4 Write an if-else statement to output "Exceeds capacity" if the value of roomCapacity is greater than 161. Otherwise, output "Does not exceed capacity". End with a newline. Ex: If the input is 163, then the output is: Exceeds capacity 1 import java.util.Scanner; 3 public class Relational { 4 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int roomCapacity; L23456789 5 11 10 11 12 } 13 } roomCapacity = scnr.nextInt (); /* Your code goes here */ 2arrow_forwardAn instructor wants to give feedback to students in an assignment according to the number of correctly solved programs. Example of feedback :Nb of correct programs Feedback 0 incomplete assignment1 partially correct assignment2 Satisfactory attempt 3 Good attempt4 Excellent attemptThe following figure shows an example of execution.Write the Java program that reads the number of correctly solved programs and displays the adequate feedback.Note: Choose your own feedback message and do not copy from the previous table. Use any of the conditional statements like if-else/ if-else-if/switch case.arrow_forward
- Q/lf 2 = a, 7 = b, 2 = c, and 10 = d are integer variables, then the next print run is It (a>=b || a==c) a=b; if (a>c || (a+c)>d) d=c; if (darrow_forwardWrite TRUE if the output of the expression is true and FALSE if the output of the expression is false.arrow_forwardAlert dont submit AI generated answer. in java pleasearrow_forwardMad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways. Complete the program to read the needed values from input, that the existing output statement(s) can use to output a short story. Ex: If the input is: Eric Chipotle 12 cars. the output is: Eric went to Chipotle to buy 12 different types of cars. 340136.2251206.qx3zay7 LAB 2.31.1: LAB: Mad Lib 0/10 ACTIVITY LabProgram.java Load default template... 1 import java.util.Scanner; 2 3 public class LabProgram { 4 5 6 7 8 9 10 11 11 went to + generic Location + to buy + wholeNumber + different types of Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. AAAAA OF ENP 12 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String firstName; String genericLocation; int…arrow_forwardWrite an if-else statement for the following: If barcode_check_digit is not equal to 7, execute group_id = 10. Else, execute group_id = barcode_check_digit. Ex: If barcode_check_digit is 14, then group_id = 10. 1 þarcode_check_digit 23 456 ... int(input()) # Program will be tested with values: 6, 7, 8, 9. Your code goes here '' 5 print(group_id)arrow_forwardWrite a flowchart and pseudocode like this: Pseudocode: Start inputmyNumber Set myAnswer-myNumber * 10 output myAnswer 1.The Dash Cell Phone Company charges customers a basic rate of $5 per month to send text messages. Additional rates are as follows: The first 100 messages per month, regardless of message length, are included in the basic bill. An additional three cents are charged for each text message after the 100th message, up to and including 300 messages. An additional two cents are charged for each text message after the 300th message. Federal, state, and local taxes add a total of 14 percent to each bill. THANKYOUUarrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT