Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. Problem 4 – Passion Days
  2. Lina is passionate about shopping. When she has some cash she runs to the mall and spends as much as she can on clothes, bags and shoes. Most of all she loves winter sales. You are challenged to analyze her strange behavior and calculate the purchases Lina makes when she enters the mall as well as the money she has when the shopping is over.
  3. On the first line you will receive the money Lina has before entering the mall. Then, when you receive the command “mall.Enter” Lina enters the mall and starts shopping until you receive the command “mall.Exit”. When Lina starts shopping, on each line you will start receiving strings representing the actions she performs. Every character in the string represents a purchase or any other action.
  4. The string can contain any character from the ASCII table, assume that the ASCII code of the character is related to the price she pays for each item. If the character is an uppercase letter, Lina gets a 50% discount, that means that you have to subtract 50% of character’s ASCII code from the money she has, if it is a lowercase, she gets 70% discount, so subtract 30% of the ASCII value of the letter, if it is ‘%’ Lina makes a purchase that halves the money she has, if it is ‘*’ she only withdraws money from her debit card and thus adds 10 leva to the money she has for shopping and doesn’t make a purchase, if it is any other ASCII character, she doesn’t get a discount, so simply subtract character’s ASCII code from the money.
  5. If the price is higher than the money she currently has she doesn’t make a purchase. Money cannot be less than 0.
  6.  
  7. Shopping is over when you receive the command “mall.Exit”. When the shopping is over you should print on the console the number of purchases she has made and the money she has. See the examples for more clarity.
  8. Input
  9. The input data should be read from the console. On the first line you will receive the money Lina has before the shopping starts. She will always receive only one command ”mall.Enter” and only one command “mall.Exit”. When you receive the command “mall.Enter” on every line you will start receiving strings containing information about the purchases/actions Lina plans to make, until you receive the command “mall.Exit”.
  10. Output
  11. The output data should be printed on the console.
  12. When the shopping ends you should print on the console the outputs depending on the number of purchases. If she didn’t make any purchases print:
  13. “No purchases. Money left: {money} lv.”
  14. If she has made at least one purchase, print:
  15. “{number of purchases} purchases. Money left: {money} lv.”
  16. Money should be formatted to the second digit after the decimal point.
  17. Constraints
  18. • Money is a floating-point number in the range [0 - 7.9 x 1028].
  19. • The number of strings between the enter and exit command will be in the range [1 - 20];
  20. • The number of characters in the string representing the actions are in the range [1 - 20];
  21. • Allowed working time: 0.1 seconds. Allowed memory: 16 MB.
  22.  
  23.  
  24. Examples
  25. Input Output Comments
  26. 110
  27. mall.Enter
  28. d
  29. mall.Exit
  30. 1 purchases. Money left: 80.00 lv.
  31. ‘d’ has ASCII code 100. It is lowercase, so Lina gets 70% discount of the price, 100 – 70% = 30.
  32. 110 – 30 = 80 lv.
  33. Input Output
  34. 110
  35. mall.Enter
  36. %
  37. mall.Exit 1 purchases. Money left: 55.00 lv.
  38.  
  39. Input Output
  40. 100
  41. mall.Enter
  42. Ab
  43. **
  44. mall.Exit 2 purchases. Money left: 58.10 lv.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement