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