Hi, I am working on my assignment: The assignment is:
The process of finding the largest value (i.e., the maximum of a group of values) is used frequently computer applications. Write a Javascript program that input a series of 10 single digit numbers as characters, determines the largest of the number and output XHTML text that displays the largest number. Your program should use 3 variables as follows:
a.) COUNTER: A counter to count to 10 (i.e. to keep track of how many number have been input and to determine when all 10 number have been processed).
b.) NUMBER: The current digit input to the program.
c.) LARGEST: The largest number found so far.
Below is my code so far:
LargestValue
import java.util.Scanner; //scanner class import declaration
public class LargestValue
{
public void determineLargestValue()
{
Scanner input = new Scanner(System.in);
int intCounter = 0;
int total = 0;
int number;
int largest;
System.out.println("Enter number: ");
largest = input.nextInt();
total += largest;
while (intCounter < 9)
{
System.out.println("Enter number: ");
number = input.nextInt();
if(number > largest)
{
largest = number;
}
total += number;
intCounter++;
}
}//end if
}//end while
System.out.printf("The total is : %d\n", total);
System.out.printf("\nThe largest of all 10 integers is: %d\n", largest, number);
}
}
LargestValueTest
class LargestValueTest
{
public void main(String args[])
{
LargestValue LargestValue1 = new LargestValue();//create object of LargestValue class to call method
LargestValue1.determineLargestValue();//find the largest integer in 10
}//end main
}//end class