Advertisement
yovkovbpfps

EXAM 20-21 Easter Shop FOR Cycle

May 1st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner
  4.  
  5. public class EasterShop {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. int cakesToBeAppraised = Integer.parseInt(scanner.nextLine());
  11.  
  12. int bestScore = 0;
  13. String bestConfectioner = "";
  14.  
  15. for (int i = 0; i < cakesToBeAppraised; i++) {
  16.  
  17. String currentConfectioner = scanner.nextLine();
  18. int currentConfectionerScore = 0;
  19.  
  20. while(true){
  21.  
  22. String inputLine = scanner.nextLine();
  23.  
  24. if (inputLine.equalsIgnoreCase("Stop"))
  25. break;
  26.  
  27. int currentJudgeScore = Integer.parseInt(inputLine);
  28. currentConfectionerScore += currentJudgeScore;
  29. }
  30.  
  31. System.out.printf("%s has %d points.\n", currentConfectioner, currentConfectionerScore);
  32.  
  33. if (bestScore < currentConfectionerScore ){
  34. bestScore = currentConfectionerScore;
  35. bestConfectioner = currentConfectioner;
  36. System.out.printf("%s is the new number 1!\n", bestConfectioner);
  37. }
  38. }
  39.  
  40. System.out.printf("%s won competition with %d points!", bestConfectioner, bestScore);;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement