Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class demo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int age = Integer.parseInt(scanner.nextLine());
- double washingmashine = Double.parseDouble(scanner.nextLine());
- int toysPrice = Integer.parseInt(scanner.nextLine());
- int toysCount = 0;
- int moneyTotal = 0;
- int addedMoney = 10;
- int moneyCount = 0;
- for (int i = 1; i <= age; i++) {
- if(i % 2 == 0){
- moneyCount++;
- moneyTotal += moneyCount * 10;
- }else{
- toysCount++;
- }
- }
- int moneyLeft = moneyTotal + toysCount * toysPrice - moneyCount;
- if(washingmashine > moneyLeft){
- double result = washingmashine - moneyLeft;
- System.out.printf("No! %.2f",result );
- }else{
- double result = moneyLeft - washingmashine;
- System.out.printf("Yes! %.2f",result );;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement