Advertisement
Valeri12580

New Home

Nov 2nd, 2018
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class newClass {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String type=scanner.nextLine();
  7. int numberFlowers=Integer.parseInt(scanner.nextLine());
  8. int budjet=Integer.parseInt(scanner.nextLine());
  9. double price=numberFlowers;
  10. double finale=0;
  11. switch(type){
  12. case "Roses":
  13. price*=5;
  14. break;
  15. case "Dahlias":
  16. price*=3.80;
  17. break;
  18. case "Tulips":
  19. price*=2.80;
  20. break;
  21. case "Narcissus":
  22. price*=3;
  23. break;
  24. case "Gladiolus":
  25. price*=2.50;
  26. break;
  27. }
  28. if (type.equals("Roses") && numberFlowers>80){
  29. price=price-(price*0.10);
  30. }else if (type.equals("Dahlias") && numberFlowers>90){
  31. price=price-(price*0.15);
  32. }else if (type.equals("Tulips") && numberFlowers>80){
  33. price=price-(price*0.15);
  34. }else if (type.equals("Narcissus") && numberFlowers<120){
  35. price=price+(price*0.15);
  36. }else if(type.equals("Gladiolus") && numberFlowers<80){
  37. price=price+(price*0.20);
  38. }
  39.  
  40.  
  41. if(budjet>price){
  42. System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.",numberFlowers,type,budjet-price);
  43. }else if(price>budjet){
  44. System.out.printf("Not enough money, you need %.2f leva more.",price-budjet);
  45. }
  46.  
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement