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