Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class New_House_4 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String flower = scanner.nextLine();
- int count = Integer.parseInt(scanner.nextLine());
- int budget = Integer.parseInt(scanner.nextLine());
- double price = 0.0;
- switch (flower) {
- case "Roses":
- price = 5 * count;
- if (count > 80) {
- price = price * 0.90;
- }
- break;
- case "Dahlias":
- price = 3.80 * count;
- if (count > 80) {
- price = price * 0.85;
- }
- break;
- case "Tulips":
- price = 2.80 * count;
- if (count > 80) {
- price = price * 0.85;
- }
- break;
- case "Narcissus":
- price = 3 * count;
- if (count < 120) {
- price = price * 1.15;
- }
- break;
- case "Gladiolus":
- price = 2.50 * count;
- if (count < 80) {
- price = price * 1.20;
- }
- break;
- }
- if (budget >= price) {
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", count, flower, budget - price);
- } else {
- System.out.printf("Not enough money, you need %.2f leva more.", price - budget);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement