Advertisement
finderabc

Clever_Lily 1

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