In: Computer Science
IN JAVA
Prompt 3:
WITH using methods create an array with numbers
int [] number = { 35, 68, 80, 34, 45, 79, 80};
Display the numbers in the array using for loop
Display the sum
Find biggest element in the array
Display the numers in the array with index numbers
Display the numers using for loop in ascending order
(sort)
typed code:
public class Main
{
public static void main(String[] args) {
int[] number =
{35,68,80,34,45,79,80};
System.out.println("#####DIAPLAY OF
ARRAY ELEMENTS#####");
for(int i =
0;i
}
System.out.println();
System.out.println("#####SUM
DISPLAY:######");
int sum = 0;
for(int i =
0;i
}
System.out.println(sum); //
printing sum
int x = number[0];
for(int i =
1;i
x = number[i]; // storing 1
variable and swaping the variables to x
} // so that biggest element will
get
}
System.out.println("biggest is " +
x); //printing biggest element
System.out.println("#####index with
elements######");
for(int i =
0;i
}
int xx = 0;
for(int i =
0;i
xx = number[i]; // numbers are
swaping if it is > j index
number[i] = number[j];
number[j] = xx;
}
}
}
System.out.println("###ASCENDING
ORDER OF ARRAYA###");
for(int i =
0;i
}
}
}
SCREEN SHOT :