Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package S3_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 count = Integer.parseInt(scanner.nextLine());
- int budget = Integer.parseInt(scanner.nextLine());
- double finalPrice = 0.0;
- switch (flowerType) {
- case "Roses":
- finalPrice = 5.0 * count;
- if(count > 80) {
- //finalPrice = finalPrice - (finalPrice * 0.10);
- finalPrice = finalPrice * 0.90;
- }
- break;
- case "Dahlias":
- finalPrice = 3.80 * count;
- if(count > 90) {
- //finalPrice = finalPrice - (finalPrice * 0.15);
- finalPrice = finalPrice * 0.85;
- }
- break;
- case "Tulips":
- finalPrice = 2.80 * count;
- if(count > 80) {
- //finalPrice = finalPrice - (finalPrice * 0.15);
- finalPrice = finalPrice * 0.85;
- }
- break;
- case "Narcissus":
- finalPrice = 3.0 * count;
- if (count < 120) {
- //finalPrice = finalPrice + (finalPrice * 0.15);
- finalPrice = finalPrice * 1.15;
- }
- break;
- case "Gladiolus":
- finalPrice = 2.50 * count;
- if (count < 80) {
- //finalPrice = finalPrice + (finalPrice * 0.20);
- finalPrice = finalPrice * 1.20;
- }
- break;
- }
- double diff = Math.abs(budget - finalPrice);
- if(budget >= finalPrice) {
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", count, 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