This is a Java programme, written by me, Plasmasia! It is a basic calculator with four functions that can support up to 15 decimal places. The code, for copypasting, is as follows: Note that this version is slightly longer. Anything with // before it is NOT code; it is a comment. You can still copypaste it, the comments are ignored when you run it. This programme is text based, meaning it runs almost exclusively in the Eclipse IDE console. It has no GUI. import static java.lang.System.out; import java.util.Scanner; class Calculator { //All this work to make a simple calculator... public static void main(final String[] args) throws InterruptedException { //Declares the class Calculator as the main class and throws an exception for Thread.sleep. char operation; //Makes a char variable called operation. out.println(" BASIC CALCULATOR"); out.println(" SUPPORTS UP TO 15 DECIMAL PLACES"); out.println(" Instructions:"); out.println(" First, type an operation. You will then be prompted to input 2 numbers."); out.println(" Preparing to recieve input. Please wait 5 seconds..."); Thread.sleep(1000); out.println(" Preparing to recieve input. Please wait 4 seconds..."); Thread.sleep(1000); out.println(" Preparing to recieve input. Please wait 3 seconds..."); Thread.sleep(1000); out.println(" Preparing to recieve input. Please wait 2 seconds..."); Thread.sleep(1000); out.println(" Preparing to recieve input. Please wait 1 seconds..."); Thread.sleep(1000); // The preceding BASIC CALCULATOR... Thread.sleep(1000) code gives the user instructions. out.println(""); out.println(""); Scanner keyboard = new Scanner(System.in); //Makes a scanner called keyboard. out.print("Type P, M, T or D. P means plus, M means minus, T means times and D means divide. The operation you are using is: "); //More instructions! operation = keyboard.next().charAt(0); //Sets the value of Char to P,M,T or D. switch (operation) { //Tells the computer what to do depending on the letter the user typed. case 'P': //If operation's value is P, do this. If it's M, do that......... out.println("What's number 1?"); double no1 = (keyboard.nextDouble()); out.println("What's number 2?"); double no2 = (keyboard.nextDouble()); double no3 = no1 += no2; out.println(no3); break; case 'M': // Using a double is important for decimals. out.println("What's number 1?"); double no4 = (keyboard.nextDouble()); out.println("What's number 2?"); double no5 = (keyboard.nextDouble()); double no6 = no4 -= no5; out.println(no6); break; case 'T': out.println("What's number 1?"); double no7 = (keyboard.nextDouble()); out.println("What's number 2?"); double no8 = (keyboard.nextDouble()); double no9 = no7 * no8; out.println(no9); break; case 'D': out.println("What's number 1?"); double no10 = (keyboard.nextDouble()); out.println("What's number 2?"); double no11 = (keyboard.nextDouble()); double no12 = no10 / no11; out.println(no12); break; default: //Tells the user they must use P, T, M and D. default is used only if all the other cases are wrong. out.println("This programme is case-sensitive, meaning you must use caps (PMTD). Please restart it. :) Also, use P,M,T, and D ONLY."); } keyboard.close(); //Stops fetching input from the keyboard. :( } }
100% @Plasmasia. Made using Eclipse Neon.