public class myArray3 { int[] n = new int[3]; int largest;
public void getData() { Scanner input = new Scanner(System.in); for (int k = 0; k < n.length; k++) { System.out.printf("Enter value for n : "); n[k] = input.nextInt(); } }
public void findLargest() { largest = n[0]; for (int k = 0; k < n.length ; k++) { if (largest < n[k]) { largest = n[k]; } } System.out.printf("\nLargest is %d\n", largest); } } |
No comments:
Post a Comment