Advertisement
bubeto1979

Untitled

Jun 15th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. /**
  5. * Created by Bubeto on 6/14/2017.
  6. */
  7. public class PassionDays1 {
  8. public static void main(String[] args) {
  9. Scanner scanner = new Scanner(System.in);
  10. //DecimalFormat format = new DecimalFormat("##.00");
  11.  
  12. double money = Double.parseDouble(scanner.nextLine());
  13. int counter = 0;
  14.  
  15. String command = scanner.nextLine();
  16.  
  17. while (!command.equalsIgnoreCase("mall.Enter")){
  18.  
  19. command = scanner.nextLine();
  20.  
  21. }
  22.  
  23. command = scanner.nextLine();
  24. double price = 0;
  25.  
  26. while (!command.equalsIgnoreCase("mall.Exit")){
  27.  
  28. String actions = command;
  29.  
  30. for (int i = 0; i < actions.length(); i++) {
  31.  
  32. char symbol = actions.charAt(i);
  33.  
  34. if (symbol >= 65 && symbol <= 90){
  35.  
  36. price += 0.5*symbol;
  37. counter++;
  38.  
  39. }
  40. else if (symbol >= 97 && symbol <= 122){
  41.  
  42. price += 0.3*symbol;
  43. counter++;
  44.  
  45. }
  46. else if (symbol == '%'){
  47.  
  48. money = money - 0.5*money;
  49. counter++;
  50.  
  51. }
  52. else if (symbol == '*'){
  53.  
  54. money += 10;
  55.  
  56. }
  57. else {
  58.  
  59. if (money > symbol){
  60. money = money - symbol;
  61. counter++;
  62.  
  63. }
  64. else {
  65. money = money - 0;
  66. }
  67.  
  68. }
  69.  
  70.  
  71.  
  72. }
  73. command = scanner.nextLine();
  74.  
  75.  
  76.  
  77.  
  78. }
  79.  
  80.  
  81.  
  82. if (counter == 0){
  83.  
  84. System.out.printf("No purchases. Money left: %.2f lv.%n", money);
  85.  
  86. }
  87. else {
  88.  
  89. System.out.printf("%d purchases. Money left: %.2f lv.%n", counter, money - price);
  90. }
  91.  
  92.  
  93.  
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement