Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class Video {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- final int CLASS_SIZE = 6;
- int[] movies = new int[CLASS_SIZE];
- int[] copies = new int[CLASS_SIZE];
- int input;
- int maxMovies = 0;
- int maxClassMovie = 0;
- int maxCopies = 0;
- int maxClassCopies = 0;
- System.out.print("Enter video codes, end the sequence with '0': ");
- input = in.nextInt();
- while(input != 0)
- {
- int curClass = input / 1000;
- int curCopies = input % 10;
- movies[curClass - 1]++;
- if(movies[curClass - 1] > maxMovies)
- {
- maxMovies = movies[curClass - 1];
- maxClassMovie = curClass;
- }
- copies[curClass - 1] += curCopies;
- if(copies[curClass - 1] > maxCopies)
- {
- maxCopies = copies[curClass - 1];
- maxClassCopies = curClass;
- }
- input = in.nextInt();
- }
- System.out.printf("The class with the max amount of movies is %d (with %d movies)\n", maxClassMovie, maxMovies);
- System.out.printf("The class with the max amount of movie copies is %d (with %d copies)\n", maxClassCopies, maxCopies);
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement