Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Program {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //declaring variables
- String flowerType = scanner.nextLine();
- //"Roses", "Dahlias", "Tulips", "Narcissus", "Gladiolus"
- int flowerCount = Integer.parseInt (scanner.nextLine());
- int budget = Integer.parseInt (scanner.nextLine());
- double price = 0;
- //initialize prices
- if(flowerType.equals("Roses")){
- price=5;
- }else if (flowerType.equals("Dahlias")){
- price=3.8;
- }else if (flowerType.equals("Tulips")){
- price=2.8;
- }else if (flowerType.equals("Narcissus")){
- price=3;
- }else if (flowerType.equals("Gladiolus")){
- price=2.5;
- }
- if(flowerType.equals("Roses")&&flowerCount>80){
- price *= 0.9;
- }else if(flowerType.equals("Dahlias")&&flowerCount>90){
- price*=0.85;
- }else if (flowerType.equals("Tulips")&&flowerCount>80){
- price*=0.85;
- }else if (flowerType.equals("Narcissus")&&flowerCount<120){
- price +=price*0.15;
- }else if (flowerType.equals("Gladiolus")&&flowerCount<80){
- price+=price*0.2;
- }
- double finalPrice = price*flowerCount;
- if(budget>finalPrice){
- double remainings = budget-finalPrice;
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.",flowerCount,flowerType,remainings);
- }else{
- double lack = finalPrice-budget;
- System.out.printf("Not enough money, you need %.2f leva more.", lack);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement