Advertisement
CR7CR7

Swimming

Dec 8th, 2022
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.61 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class SwimmingChampionship_02 {
  3.     public static void main(String[] args) {
  4.         Scanner scan =new Scanner(System.in);
  5.         /*
  6.         3
  7.        400
  8.  
  9.         5
  10.  
  11.         70.6
  12.  
  13.         15.0
  14.  
  15.         100.6
  16.  
  17.         300.59
  18.  
  19.         250.9
  20.          */
  21.         int daysCompetition =Integer.parseInt(scan.nextLine());//3
  22.         int pointsCoveredTotal =Integer.parseInt(scan.nextLine());//400
  23.         int countSwimmers =Integer.parseInt(scan.nextLine());//5
  24.         double hotelRoomPrice =Double.parseDouble(scan.nextLine());//70.6
  25.         double feeSwimmerToParticipate=Double.parseDouble(scan.nextLine());//15.0
  26.  
  27.         Double moneyToPay =(hotelRoomPrice + feeSwimmerToParticipate)*(double) countSwimmers; // expenses for each day team
  28.         double totalPoints=0; //track of points team has won
  29.         for (int day = 1; day <= daysCompetition; day++) {
  30.             double pointsPerDay=Double.parseDouble(scan.nextLine());
  31.             totalPoints =totalPoints +pointsPerDay;
  32.             if(day>1){
  33.                 totalPoints+=pointsPerDay+(pointsPerDay*0.05);
  34.             }
  35.  
  36.  
  37.  
  38.         }
  39.         if(totalPoints>=pointsCoveredTotal){
  40.             moneyToPay =moneyToPay-(moneyToPay*0.25);
  41.             System.out.println("Money left to pay:"+ moneyToPay+ "BGN");
  42.             System.out.println("The championship was successful!");
  43.         } else{
  44.             moneyToPay=moneyToPay-(moneyToPay*0.10);
  45.             System.out.println("Money left to pay:"+ moneyToPay+"BGN");
  46.             System.out.println("The championship was not successful!");
  47.         }
  48.  
  49.     }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement