Advertisement
desislava_topuzakova

Lilly

Feb 8th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class CleverLilly {
  3.     public static void main(String[] args) {
  4.         Scanner scanner=new Scanner(System.in);
  5.         int godini=Integer.parseInt(scanner.nextLine());
  6.         double peralnq=Double.parseDouble(scanner.nextLine());
  7.         double igrachka=Double.parseDouble(scanner.nextLine());
  8.         int igr=0;
  9.         double sum=0;
  10.         double startMoney=0;
  11.         double pari=0;
  12.         for (int i = 1; i <=godini ; i++)
  13.         {if(i%2==1){igr++;}
  14.         else if(i%2==0){
  15.             startMoney=startMoney+10;
  16.             sum=sum+startMoney;
  17.         pari++;}
  18.          }
  19.         double moneyIgr=igrachka*igr;
  20.         double broder=pari*1;
  21.         double ost=sum+moneyIgr-broder;
  22.         if(ost>=peralnq){double raz=ost-peralnq;
  23.             System.out.print("Yes! ");
  24.             System.out.printf("%.2f",raz);}
  25.         else if(ost<peralnq){double raz1=peralnq-ost;
  26.             System.out.print("No! ");
  27.             System.out.printf("%.2f",raz1);
  28.  
  29.         }
  30.  
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement