Advertisement
Ivakis

Плодови коктейли

Sep 14th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class demo {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String fruit = scanner.nextLine();
  8. String type = scanner.nextLine();
  9. int count = Integer.parseInt(scanner.nextLine());
  10.  
  11. double price = 0;
  12.  
  13. if(type.equals("small")){
  14.  
  15. switch (fruit) {
  16. case "Watermelon":
  17. price = 2 * 56;
  18. break;
  19. case "Mango":
  20. price = 2 * 36.66;
  21. break;
  22. case "Pineapple":
  23. price = 2 * 42.10;
  24. break;
  25. case "Raspberry":
  26. price = 2 * 20;
  27. break;
  28. }
  29. }else{
  30. if(fruit.equals("Watermelon")){
  31. price = 5 * 28.70;
  32. }else if(fruit.equals("Mango")){
  33. price = 5 * 19.60;
  34. }else if(fruit.equals("Pineapple")){
  35. price = 5 * 24.80;
  36. }else if(fruit.equals("Raspberry")){
  37. price = 5 * 15.20;
  38. }
  39. }
  40.  
  41. double result = price * count;
  42.  
  43. if(result >= 400 && result <= 1000){
  44. result = result - result * 0.15; // result * 0.85
  45. }else if(result > 1000){
  46. result = result * 0.5;
  47. }
  48.  
  49. System.out.printf("%.2f lv.", result);
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement