Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package _03_ConditionalStatementsAdvanced;
- import java.util.Scanner;
- public class NewHouse {
- 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 finalSum = 0.0;
- switch (flowerType) {
- case "Roses":
- finalSum = 5.0 * flowerCount;
- if (flowerCount > 80) {
- finalSum = finalSum * 0.90;
- //finalSum = finalSum - (finalSum * 0.10);
- // finalSum *= 0.90;
- }
- break;
- case "Dahlias":
- finalSum = 3.80 * flowerCount;
- if (flowerCount > 90) {
- finalSum = finalSum * 0.85;
- }
- break;
- case "Tulips":
- finalSum = 2.8 * flowerCount;
- if (flowerCount > 80) {
- finalSum = finalSum * 0.85;
- }
- break;
- case "Narcissus":
- finalSum = 3.0 * flowerCount;
- if (flowerCount < 120) {
- finalSum = finalSum * 1.15;
- }
- break;
- case "Gladiolus":
- finalSum = 2.50 * flowerCount;
- if (flowerCount < 80) {
- finalSum = finalSum * 1.20;
- }
- break;
- }
- double diff = Math.abs(budget - finalSum);
- if (budget >= finalSum) {
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.",
- flowerCount, flowerType, diff);
- } else {
- System.out.printf("Not enough money, you need %.2f leva more.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement