myrdok123

06. Oscars

Jan 28th, 2024
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. package W04ForLoop.Exercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06Oscars {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String actorName = scanner.nextLine();
  10.         double academyPoints = Double.parseDouble(scanner.nextLine());
  11.         int countExaminers = Integer.parseInt(scanner.nextLine());
  12.  
  13.  
  14.         double sumAllPoints = academyPoints;
  15.  
  16.         //правим цикъл -> в завосимост от броя оценяващи
  17.         for (int i = 1; i <= countExaminers; i++) {
  18.  
  19.             //Прочитаме име на оценяващия и брой точки
  20.             String examinerName = scanner.nextLine();
  21.             double currentPoints = Double.parseDouble(scanner.nextLine());
  22.  
  23.             sumAllPoints += examinerName.length() * currentPoints / 2;
  24.  
  25.             //Проверяваме дали общата сума на точките е >= 1250.5
  26.             if(sumAllPoints >= 1250.5){
  27.  
  28.                 System.out.printf("Congratulations, %s got a nominee for leading role with %.1f!", actorName, sumAllPoints);
  29.                 break;
  30.             }
  31.  
  32.         }
  33.  
  34.         //Проверяваме дали точките са < 1250.5
  35.         if(sumAllPoints < 1250.5){
  36.             //Пресметнем колко точки не са му достигнали
  37.             double diff = 1250.5 - sumAllPoints;
  38.             System.out.printf("Sorry, %s you need %.1f more!", actorName, diff);
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment