Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package L04_ForLoop;
- import java.util.Scanner;
- public class P06_Oscars {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String actorName = scanner.nextLine();
- double academyPoints = Double.parseDouble(scanner.nextLine());
- int countExaminers = Integer.parseInt(scanner.nextLine());
- double sumAllPoint = academyPoints;
- //правим цикъл за всечки оценяващи
- for (int i = 1; i <= countExaminers ; i++) {
- //прочитаме име и точки, които е дал конкретният оценяващ
- String examinerName = scanner.nextLine();
- double currentPoints = Double.parseDouble(scanner.nextLine());
- //пресмятаме колко точки трябва да прибавим към общият брой точки
- sumAllPoint += (examinerName.length() * currentPoints) / 2;
- //проверяваме дали сме достигнали 1250.5 -> ако сме ги достиганали -> принтираме и прекратяваме програмата
- if(sumAllPoint >= 1250.5){
- System.out.printf("Congratulations, %s got a nominee for leading role with %.1f!", actorName, sumAllPoint);
- break;
- }
- }
- //проверяваме дали точките са под 1250.5
- if(sumAllPoint < 1250.5){
- System.out.printf("Sorry, %s you need %.1f more!", actorName, 1250.5 - sumAllPoint);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment