Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int movies = Integer.parseInt(scanner.nextLine());
- String movie, maxMovie = "", minMovie = "";
- double rating, maxRating = 0, minRating = 10, totalRating = 0;
- for (int i = 0; i < movies; i++) {
- movie = scanner.nextLine();
- rating = Double.parseDouble(scanner.nextLine());
- if (rating > maxRating) {
- maxMovie = movie;
- maxRating = rating;
- }
- if (rating < minRating) {
- minMovie = movie;
- minRating = rating;
- }
- totalRating += rating;
- }
- System.out.printf("%s is with highest rating: %.1f\n", maxMovie, maxRating);
- System.out.printf("%s is with lowest rating: %.1f\n", minMovie, minRating);
- System.out.printf("Average rating: %.1f\n", totalRating / movies);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement