SensaBG

Untitled

May 19th, 2024
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. package VtoriModulZadachi;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class IforElse {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. double price = 100.50;
  10. double myMoney = Double.parseDouble(scanner.nextLine());
  11. boolean isMoneyEnough = price <= myMoney;
  12.  
  13.  
  14. if(isMoneyEnough) {
  15. System.out.printf("Congratulations, you can buy Daniel for %.2flv.\n", price);
  16. }else{
  17. System.out.printf("Sorry, you have %.2flv. and you cannot entirely buy Daniel because he is valued at %.2flv. " +
  18. "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);
  19.  
  20.  
  21.  
  22. }
  23. int numberOfCars = 2;
  24. int familyNumberCarsNeeded = Integer.parseInt(scanner.nextLine());
  25. boolean isCarsEnough = numberOfCars >= familyNumberCarsNeeded;
  26.  
  27. if(isCarsEnough) {
  28. 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);
  29. }else{
  30. 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);
  31. }
  32.  
  33. }
  34. }
Add Comment
Please, Sign In to add comment