Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NewHome {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String typeFlowers = scanner.nextLine();
- Integer numberFlowers = Integer.parseInt(scanner.nextLine());
- Integer budget = Integer.parseInt(scanner.nextLine());
- Double totalPrice = 0.00;
- if (typeFlowers.equals("Roses")) {
- if (numberFlowers > 80) {
- totalPrice = (numberFlowers * 5.00)-((numberFlowers * 5.00)*0.10);
- } else {
- totalPrice = numberFlowers * 5.00;
- }
- } else if (typeFlowers.equals("Dahlias")) {
- if (numberFlowers > 90) {
- totalPrice = (numberFlowers*3.80)-((numberFlowers*3.80)*0.15);
- } else {
- totalPrice = numberFlowers * 3.80;
- }
- }else if (typeFlowers.equals("Tulips")) {
- if (numberFlowers > 80) {
- totalPrice = (numberFlowers * 2.80)-((numberFlowers * 2.80)*0.15);
- } else {
- totalPrice = numberFlowers * 2.80;
- }
- }else if (typeFlowers.equals("Narcissus")) {
- if (numberFlowers < 120) {
- totalPrice = (numberFlowers * 3.00)+((numberFlowers * 3.00)*0.15);
- } else {
- totalPrice = numberFlowers * 3.00;
- }
- }else if (typeFlowers.equals("Gladiolus")) {
- if (numberFlowers < 80) {
- totalPrice = (numberFlowers * 2.50)+((numberFlowers * 2.50)*0.20);
- } else {
- totalPrice = numberFlowers * 2.50;
- }
- }
- double finalAmount = Math.abs(totalPrice - budget);
- if (totalPrice <= budget) {
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", numberFlowers, typeFlowers, finalAmount);
- } else {
- System.out.printf("Not enough money, you need %.2f leva more.", finalAmount);
- }
- }
- }
Add Comment
Please, Sign In to add comment