Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class NewHouse {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String flowersType = scanner.nextLine();
- int flowersCount = Integer.parseInt(scanner.nextLine());
- int budgetForFlowers = Integer.parseInt(scanner.nextLine());
- double rosePrice = 5.0;
- double dahliasPrice = 3.8;
- double tulipsPrice = 2.8;
- double narcissusPrice = 3.0;
- double gladiolusPrice = 2.5;
- double price = 0;
- switch (flowersType) {
- case "roses":
- price = rosePrice * flowersCount;
- break;
- case "dahlias":
- price = dahliasPrice * flowersCount;
- break;
- case "tulips":
- price = tulipsPrice * flowersCount;
- break;
- case "narcissus":
- price = narcissusPrice * flowersCount;
- break;
- case "gladiolus":
- price = gladiolusPrice * flowersCount;
- break;
- }
- double finalPrice = 0;
- if (flowersType.equals("roses") && flowersCount > 80 ) {
- finalPrice = price - (price * 0.10);
- }else if (flowersType.equals("dahlias") && flowersCount > 90 ) {
- finalPrice = price - (price * 0.15);
- }else if (flowersType.equals("tulips") && flowersCount > 80) {
- finalPrice = price - (price * 0.15);
- }else if (flowersType.equals("narcissus") && flowersCount < 120 ) {
- finalPrice = price + (price * 0.15);
- }else if (flowersType.equals("gladiolus") && flowersCount < 80 ) {
- finalPrice = price + (price * 0.20);
- }
- if (budgetForFlowers >= finalPrice) {
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.",
- flowersCount,flowersType,budgetForFlowers - finalPrice);
- }else if (finalPrice > budgetForFlowers){
- System.out.printf("Not enough money, you need %.2f leva more",finalPrice - budgetForFlowers);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement