Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Program {
- public static void main(String[] args) {
- /*
- * Kendred Thompson
- * 4th Period
- * CS 2
- * Minimum & Maximum
- */
- //Variables I changed the smallest to the largest
- int [] nums = {3, 1, 5, 3};
- int i, largest;
- largest = nums[0];
- i = 1;
- while(i < nums.length) {
- //I changed the expression < to an > so it can read the largest variable in nums
- if(nums[i] > largest) {
- largest = nums[i];
- }
- i = i + 1;
- }
- //prints the variable largest on the screen
- System.out.println(largest);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement