Advertisement
Guest User

clever lilly

a guest
Oct 20th, 2018
537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Clever_Lily {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scanner = new Scanner( System.in );
  7.  
  8.         int age = Integer.parseInt( scanner.nextLine() );
  9.         double wash = Double.parseDouble( scanner.nextLine() );
  10.         int price = Integer.parseInt( scanner.nextLine() );
  11.  
  12.         int even = age / 2;
  13.         int toys = age - even;
  14.        
  15.         int maxEven = age - age % 2;
  16.         int cash = 5 * (int)(maxEven * ((maxEven / 4.00) + 0.5));
  17.  
  18.         int c = cash + (toys * price) - even;
  19.  
  20.         if (c >= wash) System.out.printf( "Yes! %.2f", (double) (c - wash) );
  21.         else System.out.printf( "No! %.2f", (double) (wash - c) );
  22.  
  23.  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement