Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_24_April_2016 - created by borkins on 2017-05-15.
- */
- import java.util.Scanner;
- public class _04_SmartLilly
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int age = Integer.parseInt(console.nextLine());
- double priceWM = Double.parseDouble(console.nextLine());
- int priceToy = Integer.parseInt(console.nextLine());
- int toys = 0;
- double moneys = 0.0;
- for (int i = 1; i <= age; i++)
- {
- if (i % 2 == 0) {
- moneys += (i * 5) - 1;
- }
- else {
- toys++;
- }
- }
- moneys += (toys * priceToy);
- if (moneys >= priceWM) {
- System.out.printf("Yes! %.2f%n", (moneys - priceWM));
- }
- else {
- System.out.printf("No! %.2f%n", (priceWM - moneys));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment