Advertisement
yovkovbpfps

EXAM JULY 28-29 2018 05.Game Info

May 3rd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class gameInfo {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String name = scanner.nextLine();
  7. int playedGames = Integer.parseInt(scanner.nextLine());
  8. int playedTime = 0;
  9. int gamesWirhPenalties =0;
  10. int gamesWithAdditionTime =0;
  11.  
  12. for (int i = 0;i< playedGames;i++){
  13. int gameDuration = Integer.parseInt(scanner.nextLine());
  14. playedTime +=gameDuration;
  15.  
  16. if (gameDuration>90 && gameDuration<=120){
  17. gamesWithAdditionTime++;
  18. }else if (gameDuration>120){
  19. gamesWirhPenalties++;
  20. }
  21.  
  22.  
  23. }
  24. System.out.printf("%s has played %.0f minutes. Average minutes per game: %.2f%n",name,playedTime*1.0,((playedTime*1.0)/playedGames));
  25. System.out.printf("Games with penalties: %s%n",gamesWirhPenalties);
  26. System.out.printf("Games with additional time: %s%n",gamesWithAdditionTime);
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement