Concept explainers
Write an if-else statement that outputs the word "High" if the value of the variable score is greater than 100 and outputs "Low" if the value of score is at most 100. The variable score is of type int.
Explanation of Solution
Given: The variable score is of int data type.
To find: The if-else statement to implement the value “High� on the score if it is larger than hundred and “Low� on the score if it is at most hundred.
Solution:
The score is of int data type:
int score;
The if-else statement to implement the value “High� on the score if it is larger than hundred and “Low� on the score if it is at most hundred is:
if(score>100)
// Displaying the message.
System.out.println(“High�);
else
// Displaying the message.
System.out.println(“Low�);
Want to see more full solutions like this?
Chapter 3 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Concepts of Programming Languages (11th Edition)
Database Concepts (7th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Digital Fundamentals (11th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
- Statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is: There are 15 people.arrow_forwardWrite an if-else statement that asks the user to enter the speed at which he is driving. If the speed is more than 50 print ‘Speed in limit’, else print ‘Speed should be checked’.arrow_forward28. If originally x=4, what is the value of x after the evaluation of the expression: x+=4arrow_forward
- Write a statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is: There are 15 people.arrow_forwardWrite 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.arrow_forwardWrite 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.arrow_forward
- 1. 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_forwardThe following statement should determine if x is not greater than 20. What is wrong with it?arrow_forwardScenario: 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_forward
- Assume that d is a double variable. Write an if statement that assigns d to the int variable i if the value in d is not larger than the maximum value for an int. i (int) d; System.out.println(i); } Submit X Incorrect. Try again.arrow_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_forwardWrite TRUE if the truth value of the statement is incorrect, otherwise write FALSE.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education