Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Garden
- double expenses = 0;
- Scanner keyboard = new Scanner(System.in);
- System.out.print("Enter budged: ");
- int budged = keyboard.nextInt();
- System.out.print("Enter type of flowers: ");
- String typeOfFlowers = keyboard.next();
- System.out.print("Count of flowers: ");
- int count = keyboard.nextInt();
- System.out.print("Enter price of flowers: ");
- double price = keyboard.nextDouble();
- switch (typeOfFlowers) {
- case "roses":
- if (count > 80) {
- expenses = (count * price) * 0.9;
- }else {
- expenses = count * price;
- }
- break;
- case "dahlias":
- if ( count > 90) {
- expenses = (count * price) * 0.85;
- } else {
- expenses = count * price;
- }
- break;
- case "tulips":
- if (count > 90){
- expenses = (count * price) * 0.85;
- }else {
- expenses = price * count;
- }
- break;
- case "narcissus":
- if (count < 120) {
- expenses = (price * count) * 1.15;
- }else {
- expenses = (price * count);
- }
- break;
- case "gladiolus":
- if (count < 80){
- expenses = (price * count) * 1.20;
- }else {
- expenses = (price * count);
- }
- break;
- default: {
- System.out.println("We don't offer this kind of flowers.");
- }
- }
- if (budged >= expenses) {
- System.out.printf("Yes, you have a great garden with %d %s and %.2f left lv." ,count, typeOfFlowers, (budged - expenses));
- } else{
- System.out.printf("Not enough money. Yoy are short of %.2f lv.", expenses - budged );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement