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