valiamaximova1

Club

Apr 26th, 2020 (edited)
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Club4 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         double wantedMoney = Double.parseDouble(scan.nextLine());
  7.         double sumPrice = 0;
  8.         String name = scan.nextLine();
  9.         while (!name.equals("Party!")) {
  10.             int number = Integer.parseInt(scan.nextLine());
  11.             double cena = name.length();
  12.             double sum = cena * number;
  13.  
  14.  
  15.             if ((sumPrice % 10 ) % 2 == 1) {
  16.                 sumPrice = sumPrice * 0.75;
  17.             }
  18.             sumPrice += sum;
  19.             if (sumPrice >= wantedMoney) {
  20.                 System.out.println("Target acquired.");
  21.                 break;
  22.             }
  23.            
  24.             name = scan.nextLine();
  25.         }
  26.        
  27.         if (name.equals("Party!")) {
  28.             double diff = wantedMoney - sumPrice;
  29.             System.out.printf("We need %.2f leva more.%n", diff);
  30.         }
  31.        
  32.         System.out.printf("Club income - %.2f leva.", sumPrice);
  33.     }
  34. }
Add Comment
Please, Sign In to add comment