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)
- Write 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 a statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is: There are 15 people.arrow_forwardThe following statement should determine if x is not greater than 20. What is wrong with it?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_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_forwardPlease answer in matlab code.arrow_forward
- Write a program that asks the user for a number in the range of 1 through 7. The program should display the corresponding day of the week, where 1 = Monday, 2 = Tuesday and so forth. If the user types in a 6 then "Saturday" should be printed on the screen. For help with Input statements see: Input Function The program should print an error message if the user enters a number that is outside the range of 1 through 7. For help with If statements and conditions see the following pages: If-Else Statements and Operators. Name the source code file yourName_HW4_1.py. Test and run the program. Capture the output console and save it as an image file named yourName_HW3_output4_1.jpg. Submit the .py and the image files through Canvas.arrow_forwardAssume 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_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_forward
- An 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_forwardConditional Statements You have $12,000 to buy a car.You're given a program which takes the price of car as an input.TaskOutput "yes" if the price is lower than or equal to 12,000.Sample Input11000Sample Outputyes Use the if statement to check the required condition.arrow_forward> Example: Rewrite the previous code by using nested if condition. grade (x) := if x2 60 grade (50) = "you fail" out e "you get a D" if x2 70 grade (61) = "you get a D" out + "you get a C" if x2 80 grade (75) = "you get a C" out + "you get a B" grade (88) = "you get a B" out "you get an A" if x2 90 out + "you fail" otherwise grade (93) = "you get an A" outarrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,