Advertisement
Dilyana86

Untitled

Apr 14th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class dreamItem290315evening {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. String[] input = scan.nextLine().split("/");
  7. String month = input[0];
  8. double perHour = Double.parseDouble(input[1]);
  9. double hours = Double.parseDouble(input[2]);
  10. double price = Double.parseDouble(input[3]);
  11. int days = 0;
  12.  
  13. switch(month){
  14. case "Feb":
  15. days = 28;
  16. break;
  17. case "Apr":
  18. case "June":
  19. case "Sept":
  20. case "Nov":
  21. days = 30;
  22. break;
  23. default:
  24. days = 31;
  25. break;
  26. }
  27. days = days - 10;
  28. double total = days * perHour * hours;
  29. if(total > 700){
  30. total = total + total * 0.10;
  31. }
  32. if (total - price >= 0){
  33. System.out.printf("Money left = %.2f leva.",total - price);
  34. }else{
  35. System.out.printf("Not enough money. %.2f leva needed.",Math.abs(price - total));
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement