Write out the changes you would make to above java program


(a) Write the output of the following Java program fragment, assuming that Scanner has

been properly imported. When prompted, the user enters the following: 1 2 3 4

System.out.print ("Enter four integers: ");

Scanner stdin = new Scanner(System.in);

int num1 = stdin.nextInt ( );

int num2 = stdin.nextInt ( );

int num3 = stdin.nextInt ( );

int num4 = stdin.nextInt ( );

int result;

result = (num1 + num2 + num3 + num4);

System.out.print ("The result is: ");

System.out.println (result);

(b) Write out the changes you would make to above Java program segment to print the average of the four input numbers (Reminder: int division results in losing fractional part)

Solution Preview :

Prepared by a verified Expert
Business Management: Write out the changes you would make to above java program
Reference No:- TGS02564095

Now Priced at $10 (50% Discount)

Recommended (93%)

Rated (4.5/5)