Question: Write a for loop that iterates 7 times to find the maximum value in a list. In each iteration: Read an integer value from input

Write a for loop that iterates 7 times to find the maximum value in a list. In each iteration:
Read an integer value from input into variable inVal.
If inVal is greater than largestVal, assign largestVal with inVal.
In the first iteration, assign largestVal with inVal since the first value read is the largest value seen so far.
Ex: If the input is 9525956510555, then the output is:
95 import java.util.Scanner;
public class LargestValues {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
int inVal;
int largestVal =0;
int i;
/* Your code goes here */
System.out.println(largestVal);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!