Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class LiLis_Gifts {
- public static void main(String[] args) {
- Scanner key = new Scanner(System.in);
- System.out.print("age: ");
- int age = Integer.parseInt(key.nextLine());
- System.out.print("toys' price: ");
- int toyPrice = Integer.parseInt(key.nextLine());
- System.out.print("wash machine price: ");
- int machinePrice = Integer.parseInt(key.nextLine());
- int moneyTimes = 0;
- int sumByMoney = 0;
- int remainingSum = 0;
- int toys = 0;
- for (int i = 1; i <= age; i++) {
- if (i % 2 == 0) {
- moneyTimes++;
- sumByMoney += moneyTimes * 10; //sumByMoney = sumByMoney + (moneyTimes * 10);
- remainingSum = sumByMoney - moneyTimes;
- } else {
- toys++;
- }
- }
- // System.out.println("Times money received: " + moneyTimes);
- // System.out.println("Total cash: " + sumByMoney);
- // System.out.println("Remained sum after brother's pinches: " + remainingSum);
- // System.out.printf("The sum by toys sell: %d lv.%n", toyPrice * toys);
- System.out.println("--------------------------------------------------");
- int totalSum = remainingSum + (toyPrice * toys);
- System.out.printf("Total sum: %d lv.%n", totalSum);
- System.out.println("--------------------------------------------------");
- if (totalSum >= machinePrice){
- System.out.printf("Yes, Lily can buy the wash machine. She will remain %d lv.", totalSum - machinePrice);
- } else {
- System.out.printf("No, Lily can't buy the wash machine. She is short of %d lv.", machinePrice - totalSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement