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