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