Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class dreamItem290315evening {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String[] input = scan.nextLine().split("/");
- String month = input[0];
- double perHour = Double.parseDouble(input[1]);
- double hours = Double.parseDouble(input[2]);
- double price = Double.parseDouble(input[3]);
- int days = 0;
- switch(month){
- case "Feb":
- days = 28;
- break;
- case "Apr":
- case "June":
- case "Sept":
- case "Nov":
- days = 30;
- break;
- default:
- days = 31;
- break;
- }
- days = days - 10;
- double total = days * perHour * hours;
- if(total > 700){
- total = total + total * 0.10;
- }
- if (total - price >= 0){
- System.out.printf("Money left = %.2f leva.",total - price);
- }else{
- System.out.printf("Not enough money. %.2f leva needed.",Math.abs(price - total));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement