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 modelCount = Integer.parseInt(scanner.nextLine()),
- model, rating, sales;
- double totalSales = 0, totalRating = 0;
- for (int i = 0; i < modelCount; i++) {
- model = Integer.parseInt(scanner.nextLine());
- rating = model % 10;
- sales = model / 10;
- totalRating += rating;
- totalSales += switch (rating) {
- case 2 -> 0;
- case 3 -> 0.5;
- case 4 -> 0.7;
- case 5 -> 0.85;
- default -> 1;
- } * sales;
- }
- System.out.printf("%.2f\n%.2f\n", totalSales, totalRating / modelCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement