Advertisement
veronikaaa86

05. Oscars

Aug 14th, 2021
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. package examPreparation;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P04Oscars {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String actorName = scanner.nextLine();
  10. double pointsAcademy = Double.parseDouble(scanner.nextLine());
  11. int judges = Integer.parseInt(scanner.nextLine());
  12.  
  13. double totalPoints = pointsAcademy;
  14. for (int i = 0; i < judges; i++) {
  15. String judgeName = scanner.nextLine();
  16. double pointsJudge = Double.parseDouble(scanner.nextLine());
  17.  
  18. int lengthName = judgeName.length();
  19. double calculatedPoints = (lengthName * pointsJudge) / 2;
  20. totalPoints = totalPoints + calculatedPoints;
  21.  
  22. if (totalPoints > 1250.5) {
  23. break;
  24. }
  25. }
  26.  
  27. if (totalPoints > 1250.5) {
  28. System.out.printf("Congratulations, %s got a nominee for leading role with %.1f!",
  29. actorName, totalPoints);
  30. } else {
  31. System.out.printf("Sorry, %s you need %.1f more!",
  32. actorName, 1250.5 - totalPoints);
  33. }
  34.  
  35. }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement