Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA LANGUAGE Please Solve both Exercises (I'll recommend you) Exercise 1: 1-Which of the following expressions yields an integer between 20 and 90, inclusive? a.

JAVA LANGUAGE Please Solve both Exercises (I'll recommend you) Exercise 1: 1-Which of the following expressions yields an integer between 20 and 90, inclusive?

a. (int)(Math.random() * 71) + 20

b. (int)(Math.random() * 90) + 20

c. (int)(Math.random() * 20) + 90

d. (int)(Math.random() * 21) + 71 -------------------------------------------------------------- 2-

The following code displays all numbers from 72 to 1000 in the same line. Modify it in order to display numbers from 72 to 1000 five per line.

for(int i = 72; i <= 1000; i++)

System.out.print(i + " "); ----------------------------------------------------------------------------- 3-

  1. What makes this loop an infinite loop?

int count = 0, even=0;

while(count < 10){

if(count % 2 == 0)

even ++;

} --------------------------------------------------------------------------------------------------------------------------------- Exercise 2:

Write a program that asks the user to enter the grade of three students. The program must display the highest grade. Note that the grades must be between 0 and 100. Do NOT use loops, otherwise you will not get the mark.

Sample run 1:

Enter the grade of student 1: 70

Enter the grade of student 2: 95

Enter the grade of student 3: 87

The highest grade is 95.0

Sample run 2:

Enter the grade of student 1: 62

Enter the grade of student 2: -75

Enter the grade of student 3: 98

Wrong entry all grades should be between 0 and 100

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago