Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- /**
- * Created by Bubeto on 6/14/2017.
- */
- public class PassionDays1 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //DecimalFormat format = new DecimalFormat("##.00");
- double money = Double.parseDouble(scanner.nextLine());
- int counter = 0;
- String command = scanner.nextLine();
- while (!command.equalsIgnoreCase("mall.Enter")){
- command = scanner.nextLine();
- }
- command = scanner.nextLine();
- double price = 0;
- while (!command.equalsIgnoreCase("mall.Exit")){
- String actions = command;
- for (int i = 0; i < actions.length(); i++) {
- char symbol = actions.charAt(i);
- if (symbol >= 65 && symbol <= 90){
- price += 0.5*symbol;
- counter++;
- }
- else if (symbol >= 97 && symbol <= 122){
- price += 0.3*symbol;
- counter++;
- }
- else if (symbol == '%'){
- money = money - 0.5*money;
- counter++;
- }
- else if (symbol == '*'){
- money += 10;
- }
- else {
- if (money > symbol){
- money = money - symbol;
- counter++;
- }
- else {
- money = money - 0;
- }
- }
- }
- command = scanner.nextLine();
- }
- if (counter == 0){
- System.out.printf("No purchases. Money left: %.2f lv.%n", money);
- }
- else {
- System.out.printf("%d purchases. Money left: %.2f lv.%n", counter, money - price);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement