myrdok123

06. Oscars

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