Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CruiseGames_04 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- int countGames = Integer.parseInt(scanner.nextLine());
- double sumPoints = 0;
- double sumPointsVolley = 0;
- double sumPointsTennis = 0;
- double sumPointsBadmin = 0;
- double averageVolley = 0;
- double averageTennis = 0;
- double averageBadmin = 0;
- int counterVolley=0;
- int counterTennis=0;
- int counterBadmin=0;
- for (int gameNumber = 0; gameNumber < countGames; gameNumber++) {
- String gameName = scanner.nextLine();
- double points = Double.parseDouble(scanner.nextLine());
- if (gameName.equals("volleyball")){
- points = points * 1.07;
- counterVolley++;
- sumPointsVolley = sumPointsVolley + points;
- averageVolley = sumPointsVolley / counterVolley;
- averageVolley = Math.floor(averageVolley);
- } else if (gameName.equals("tennis")){
- points =points * 1.05;
- counterTennis++;
- sumPointsTennis = sumPointsTennis + points;
- averageTennis = sumPointsTennis/counterTennis;
- averageVolley = Math.floor(averageVolley);
- }else if (gameName.equals("badminton")){
- points = points * 1.02;
- counterBadmin++;
- sumPointsBadmin = sumPointsBadmin + points;
- averageBadmin = sumPointsBadmin/counterBadmin;
- averageBadmin = Math.floor((averageBadmin));
- }
- sumPoints = sumPointsVolley+sumPointsTennis+sumPointsBadmin;
- }
- sumPoints = Math.floor(sumPoints);
- if (averageVolley >= 75 && averageTennis>=75 && averageBadmin>=75){
- System.out.printf("Congratulations, %s! You won the cruise games with %.0f points.",name, sumPoints);
- }else {
- System.out.printf("Sorry, %s, you lost. Your points are only %.0f.", name, sumPoints);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement