diff --git a/src/xs_ibdpcompsci_javaintro/practice1.java b/src/xs_ibdpcompsci_javaintro/practice1.java deleted file mode 100644 index f853121..0000000 --- a/src/xs_ibdpcompsci_javaintro/practice1.java +++ /dev/null @@ -1,66 +0,0 @@ -package xs_ibdpcompsci_javaintro; -import java.util.*; - -class RPN_Calculator { - static ArrayList request_input() { - Scanner input = new Scanner(System.in); - - // Initialize variables. - ArrayList USER_INPUTS = new ArrayList(); - String USER_INPUT_CURRENT = ""; - Boolean USER_INPUT_MORE = true; - - // Loop for input. - do { - USER_INPUT_CURRENT = input.nextLine(); - - if (USER_INPUT_CURRENT.isEmpty() || USER_INPUT_CURRENT.isBlank()) { - USER_INPUT_MORE = false; - } else if (USER_INPUT_CURRENT.matches("-?\\d+(\\.\\d+)?")) { - USER_INPUTS.add(Float.parseFloat(USER_INPUT_CURRENT)); - } else { - if (USER_INPUT_CURRENT.matches("[+\\-*\\/^]") && (USER_INPUTS.size() > 2)) { - USER_INPUTS.add(USER_INPUT_CURRENT); - } else if (USER_INPUT_CURRENT.toLowerCase() == "exit") { - System.exit(0); - } else { - // The user inputs a wrong code. Let the user edit it. - System.out.println("\\033[A"); - }; - }; - } while (USER_INPUT_MORE == true); - - input.close(); - return (USER_INPUTS); - } - - static float calculate(ArrayList ENTRIES_LIST, String OPERATION) { - // Calculate length. - int ENTRIES_LIST_LENGTH = ENTRIES_LIST.size(); - - float OPERATION_RESULT = (float) ENTRIES_LIST.get(0); - - if (ENTRIES_LIST_LENGTH > 1) { - for (int ENTRY_CURRENT = 1; ENTRY_CURRENT < ENTRIES_LIST_LENGTH; ENTRY_CURRENT++) { - if (OPERATION == "+") { - OPERATION_RESULT += (float) ENTRIES_LIST.get(ENTRY_CURRENT); - } else if (OPERATION == "-") { - OPERATION_RESULT -= (float) ENTRIES_LIST.get(ENTRY_CURRENT); - }; - }; - }; - - return (OPERATION_RESULT); - }; - - - public static void main(String[] args) { - // Initialize the input numbers. - ArrayList NUMBERS_INPUT = new ArrayList(); - while (true) { - NUMBERS_INPUT = request_input(); - - - } - } -} \ No newline at end of file