Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package VtoriModulZadachi;
- import java.util.Scanner;
- public class IforElse {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double price = 100.50;
- double myMoney = Double.parseDouble(scanner.nextLine());
- boolean isMoneyEnough = price <= myMoney;
- if(isMoneyEnough) {
- System.out.printf("Congratulations, you can buy Daniel for %.2flv.\n", price);
- }else{
- System.out.printf("Sorry, you have %.2flv. and you cannot entirely buy Daniel because he is valued at %.2flv. " +
- "However you can rent him for low as 0.10cents per hour. Let's do not forget that he is a junkie after all\n", myMoney, price);
- }
- int numberOfCars = 2;
- int familyNumberCarsNeeded = Integer.parseInt(scanner.nextLine());
- boolean isCarsEnough = numberOfCars >= familyNumberCarsNeeded;
- if(isCarsEnough) {
- System.out.printf("You have the needed total of %d car/s for the whole family as overall you have in the garage %d cars.", familyNumberCarsNeeded, numberOfCars);
- }else{
- System.out.printf("You don't have enough cars for the whole family. You need total of %d while you have only %d", familyNumberCarsNeeded, numberOfCars);
- }
- }
- }
Add Comment
Please, Sign In to add comment