Guest User

Untitled

a guest
Dec 14th, 2019
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. public class SvadbenaUkrasa {
  6.  
  7. public static void main(String[] args) throws IOException {
  8.  
  9.  
  10. BufferedReader reader =
  11. new BufferedReader(new InputStreamReader(System.in));
  12.  
  13.  
  14. double priceBaloon = 0.1;
  15. double priceFLowers = 1.5;
  16. double priceCandels = 0.5;
  17. double priceRibbon = 2;
  18.  
  19. int totalBallon = 0;
  20. int totalFlowers = 0;
  21. int totalCandels = 0;
  22. int totalRibbon = 0;
  23.  
  24.  
  25. double budget = Double.parseDouble(reader.readLine());
  26. String command = "";
  27.  
  28.  
  29. while (!command.equals("stop")&&budget>=0){
  30.  
  31. command = reader.readLine();
  32. switch (command) {
  33. case "flowers": {
  34. int number = Integer.parseInt(reader.readLine());
  35. budget = budget - (number * priceFLowers);
  36. totalFlowers += number;
  37. break;
  38. }
  39. case "balloons": {
  40. int number = Integer.parseInt(reader.readLine());
  41. budget = budget - (number * priceBaloon);
  42. totalBallon += number;
  43. break;
  44. }
  45. case "candles": {
  46. int number = Integer.parseInt(reader.readLine());
  47. budget = budget - (number * priceCandels);
  48. totalCandels += number;
  49. break;
  50. }
  51. case "ribbon": {
  52. int number = Integer.parseInt(reader.readLine());
  53. budget = budget - (number * priceRibbon);
  54. totalRibbon += number;
  55. break;
  56. }
  57. }
  58.  
  59.  
  60.  
  61.  
  62. }
  63.  
  64. if (budget<0){
  65. System.out.println("All money spent!");
  66. }
  67.  
  68.  
  69. System.out.printf("Purchased decoration is %d balloons, %s m ribbon, %s flowers and %s candles.",totalBallon,totalRibbon,totalFlowers,totalCandels);
  70. }
  71.  
  72.  
  73. }
RAW Paste Data