Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //practical 1 question 1
- package prac1;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- /**
- *
- * @author Student
- */
- public class Prac1 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- List<Integer> scores = new ArrayList();
- int min, max, average, sum=0;
- scores.add(100);
- scores.add(50);
- scores.add(80);
- scores.add(40);
- scores.add(99);
- min = Collections.min(scores);
- max = Collections.max(scores);
- //display all test scores
- for(int score:scores){
- System.out.println(score + ", ");
- }
- //display the lowest score
- System.out.println("\nMin: " + min);
- //display the highest score
- System.out.println("\nMax: " + max);
- //display the average score
- for(int score:scores){
- sum += score;
- }
- average = sum/scores.size();
- System.out.println("\nAverage: " + average);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement