Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.PrintStream;
- import java.util.Scanner;
- public class EP05NewHome {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String flowerType = scanner.nextLine();
- int flowersAmount = Integer.parseInt(scanner.nextLine());
- int budget = Integer.parseInt(scanner.nextLine());
- double price = 0;
- if(flowerType.equalsIgnoreCase("Roses")) {
- price = flowersAmount * 5;
- if (flowersAmount > 80) {
- price *= 0.9;
- }
- }
- else if (flowerType.equalsIgnoreCase("Dahlias")) {
- price = flowersAmount * 3.8;
- if (flowersAmount > 90) {
- price *= 0.85;
- }
- }
- else if (flowerType.equalsIgnoreCase("Tulips")) {
- price = flowersAmount * 2.8;
- if (flowersAmount > 80) {
- price *= 0.85;
- }
- }
- else if (flowerType.equalsIgnoreCase("Narcissus")) {
- price = flowersAmount * 3;
- if (flowersAmount < 120) {
- price += (price * 0.15);
- }
- }
- else if(flowerType.equalsIgnoreCase("Gladiolus")) {
- price = flowersAmount * 2.50;
- if (flowersAmount < 80) {
- price += (price * 0.20);
- }
- }
- double difference = Math.abs(budget - price);
- if (budget >= price) {
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersAmount, flowerType, difference);
- }
- else {
- System.out.printf("Not enough money, you need %.2f leva more.", difference);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment