Originally Posted by
Milestone45
Ok I fixed It now can help you help insert a SPLASH SCREEN within the code.
import java.util.Scanner;
public class Calculator
{
* *public static void main(String[] args)
* *{
* ** *Scanner keyboard= new Scanner(System.in);
* ** *System.out.print("Enter calculator choice: ");
* ** *int userChoice = keyboard.nextInt();
* ** *
* * * * * * * * //initialise variables for choice 1
* ** *int num1 = 0;
* ** *int num2 = 0;
* ** *String arithmeticOperation = "";
* ** *
* * * * * * * * //initialise variables for choices 2 and 3
* ** *int length = 0;
* ** *int width = 0;
* ** *int height = 0;
* ** *
* ** *switch(userChoice)
* ** *{
* ** *case 1:
* ** ** *System.out.println("Arithmetic Calculator");
* ** ** *break;
* ** *case 2:
* ** ** *System.out.println("Area Calculator");
* ** ** *break;
* ** *case 3:
* ** ** *System.out.println("Volume Calculator");
* ** ** *break;
* ** *}
* ** *
* ** *if(userChoice == 1)
* ** *{
* ** ** *System.out.print("Enter first number: ");
* ** ** *num1 = keyboard.nextInt();
* ** ** *
* ** ** *System.out.print("Enter second number: ");
* ** ** *num2 = keyboard.nextInt();
* ** ** *
* ** ** *System.out.print("Enter Arithmetic Operation: ");
* ** ** *arithmeticOperation = keyboard.next();
* ** ** *
* ** ** *System.out.println("Answer = " + arithmeticCalculator(num1, num2, arithmeticOperation));
* ** *}
* ** *else if(userChoice == 2)
* ** *{
* ** ** *System.out.print("Enter Length of the square: ");
* ** ** *length = keyboard.nextInt();
* ** ** *
* ** ** *System.out.print("Enter Width of the square: ");
* ** ** *width = keyboard.nextInt();
* ** ** *
* ** ** *System.out.println("Area = " + areaCalculator(length, width) + " Units^2");
* ** *}
* ** *else if(userChoice == 3)
* ** *{
* ** ** *System.out.print("Enter Length of the cube: ");
* ** ** *length = keyboard.nextInt();
* ** ** *
* ** ** *System.out.print("Enter Width of the cube: ");
* ** ** *width = keyboard.nextInt();
* ** ** *
* ** ** *System.out.print("Enter Height of the cube: ");
* ** ** *height = keyboard.nextInt();
* ** ** *
* ** ** *System.out.println("Volume = " + volumeCalculator(length, width, height) + " Units^3");
* ** *}
* ** *else
* ** *{
* ** ** *System.out.println("Error, choose a number between 1 and 3 inclusive.");
* ** *}
* *}
* *
* *
* *public static int arithmeticCalculator(int number1, int number2, String arithmeticOperator)
* *{
* ** * if(arithmeticOperator.equals("+"))
* ** * {
* ** * * * return number1 + number2;
* ** * }
* ** * else if(arithmeticOperator.equals("-"))
* ** * {
* ** * * * return number1 - number2;
* ** * }
* ** * else
* ** * {
* ** * * * return 0;
* ** * }
* *}
* *
* * * *
* *public static int areaCalculator(int length, int width)
* *{
* ** *return length * width;
* *}
* *
* *
* *public static int volumeCalculator(int length, int width, int height)
* *{
* ** *return length * width * height;
* *}
}
]