Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Zadacha94 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String type= sc.nextLine();
- int ammount=Integer.parseInt(sc.nextLine());
- int budget=Integer.parseInt(sc.nextLine());
- double leftover;
- double price=0;
- double cost=price*ammount;
- switch (type){
- case "Roses":
- price=5;
- cost=price*ammount;
- if (ammount>=80)
- {
- price=price*0.9;
- cost=price*ammount;
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- leftover= budget - cost;
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+leftover+" leva left.");
- }
- }
- else if (ammount<80)
- {
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+(budget-cost)+" leva left.");
- }
- }
- break;
- case "Dahlias":
- price=3.8;
- cost=price*ammount;
- if (ammount>=90)
- {
- price=price*0.85;
- cost=price*ammount;
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- leftover= budget - cost;
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+leftover+" leva left.");
- }
- }
- else if (ammount<90)
- {
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+(budget-cost)+" leva left.");
- }
- }
- break;
- case "Tulips":
- price=2.8;
- cost=price*ammount;
- if (ammount>=80)
- {
- price=price*0.85;
- cost=price*ammount;
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- leftover= budget - cost;
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+leftover+" leva left.");
- }
- }
- else if (ammount<80)
- {
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+(budget-cost)+" leva left.");
- }
- }
- break;
- case "Narcissus":
- price=3;
- cost=price*ammount;
- if (ammount<120)
- {
- price=price*1.15;
- cost=price*ammount;
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- leftover= budget - cost;
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+leftover+" leva left.");
- }
- }
- else if (ammount>=120)
- {
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+(budget-cost)+" leva left.");
- }
- }
- break;
- case "Gladiolus":
- price=2.50;
- cost=price*ammount;
- if (ammount<80)
- {
- price=price*1.2;
- cost=price*ammount;
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- leftover= budget - cost;
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+leftover+" leva left.");
- }
- }
- else if (ammount>=80)
- {
- if (cost>budget){
- System.out.println("Not enough money, you need "+(cost-budget)+" leva more.");
- }
- else if (cost<=budget){
- System.out.println("Hey, you have a great garden with "+ammount+type+" and "+(budget-cost)+" leva left.");
- }
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement