Advertisement
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 flowerType = scanner.nextLine();
- int flowerAmount = Integer.parseInt(scanner.nextLine());
- int budget = Integer.parseInt(scanner.nextLine());
- double rosesPrice = 5.00;
- double dahliasPrice = 3.80;
- double tulipsPrice = 2.80;
- double narcissusPrice = 3.00;
- double gladiolusPrice = 2.50;
- double totalIncome = 0.0;
- switch (flowerType) {
- case "Roses":
- totalIncome = flowerAmount * rosesPrice;
- if (flowerAmount > 80) {
- totalIncome = totalIncome * 0.90;
- }
- break;
- case "Dahlias":
- totalIncome = flowerAmount * dahliasPrice;
- if (flowerAmount > 90) {
- totalIncome = totalIncome * 0.85;
- }
- break;
- case "Tulips":
- totalIncome = flowerAmount * tulipsPrice;
- if (flowerAmount > 80) {
- totalIncome = totalIncome * 0.85;
- }
- break;
- case "Narcissus":
- totalIncome = flowerAmount * narcissusPrice;
- if (flowerAmount < 120) {
- totalIncome = totalIncome * 1.15;
- }
- break;
- case "Gladiolus":
- totalIncome = flowerAmount * gladiolusPrice;
- if (flowerAmount < 80) {
- totalIncome = totalIncome * 1.20;
- }
- break;
- }
- if (totalIncome < budget) {
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowerAmount, flowerType, (budget - totalIncome));
- } else {
- System.out.printf("Not enough money, you need %.2f leva more.", (totalIncome - budget));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement