Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ExsWeek_03;
- import java.util.Scanner;
- public class NewHouse {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String flowersName = scanner.nextLine();
- int flowersNum = Integer.parseInt(scanner.nextLine());
- int budget = Integer.parseInt(scanner.nextLine());
- double totalSum = 0;
- switch (flowersName){
- case "Roses":
- totalSum = flowersNum * 5;
- if (flowersNum > 80){
- totalSum = totalSum - totalSum * 0.10;
- }
- break;
- case "Dahlias":
- totalSum = flowersNum * 3.80;
- if (flowersNum > 90){
- totalSum = totalSum -totalSum * 0.15;
- }
- break;
- case "Tulips":
- totalSum = flowersNum * 2.80;
- if (flowersNum > 80){
- totalSum = totalSum - totalSum * 0.15;
- }
- break;
- case "Narcissus":
- totalSum = flowersNum * 3;
- if (flowersNum < 120){
- totalSum = totalSum + totalSum * 0.15;
- }
- break;
- case "Gladiolus":
- totalSum = flowersNum * 2.50;
- if (flowersNum < 80){
- totalSum = totalSum + totalSum * 0.20;
- }
- break;
- }
- double diff = Math.abs(budget - totalSum);
- if (budget >= totalSum){
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersNum, flowersName, diff);
- }else{
- System.out.printf("Not enough money, you need %.2f leva more.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement