Arithmetic on numbers provided by user import java.util.Scanner;


public class CAI {


    public static void main(String[] args) {

        Scanner cai = new Scanner(System.in);

        System.out.println("Caluclator");

        System.out.println("\nHere are your options:");
        System.out.println("\n1. Addition");
        System.out.println("2. Subtraction");
        System.out.println("3. Division");
        System.out.println("4. Multiplication");

        System.out.print("\nWhat would you like to do?: ");
        int choice = cai.nextInt();
        System.out.println();


        if (choice == 1){
            addition();
        }
        else if (choice == 2){
            subtraction();
        }
        else if (choice == 3){
            division();
        }
        else if (choice == 4){
            multiplication();
        }

        System.out.println();
        cai.close();
    }

    public static void addition(){

        int One, Two;
        Scanner cai = new Scanner(System.in);

        System.out.println("Addition");

        System.out.print("\nFirst Number: ");
        One = cai.nextInt();

        System.out.print("\nSecond Number: ");
        Two = cai.nextInt();

        cai.close();
        System.out.println("\nSum: " + One + " + " + Two + " = " + (One + Two));
    }

    public static void subtraction(){
        int One, Two;
        Scanner cai = new Scanner(System.in);

        System.out.println("Subtraction");

        System.out.print("\nFirst Number: ");
        One = cai.nextInt();

        System.out.print("\nSecond Number: ");
        Two = cai.nextInt();

        cai.close();
        System.out.println("\nSum: " + One + " - " + Two + " = " + (One - Two));
    }

    public static void division(){
        int One, Two;
        Scanner cai = new Scanner(System.in);

        System.out.println("Division");

        System.out.print("\nFirst Number: ");
        One = cai.nextInt();

        System.out.print("\nSecond Number: ");
        Two = cai.nextInt();

        cai.close();
        System.out.println("\nSum: " + One + " / " + Two + " = " + (One / Two));
    }

    public static void multiplication(){
        int One, Two;
        Scanner cai = new Scanner(System.in);

        System.out.println("Multiplication");

        System.out.print("\nFirst Number: ");
        One = cai.nextInt();

        System.out.print("\nSecond Number: ");
        Two = cai.nextInt();

        cai.close();
        System.out.println("\nSum: " + One + " x " + Two + " = " + (One * Two));
    }
}


ok So i have this project for a class and what i am trying to do is make addition questions that would pick the numbers i chose randomly and make questions out of them, i am also trying to have the user to write the answer and let them know if the answer they chose is right or wrong. I know its a lot to ask but my project is due in 2 hours and i need help
Validating user input
The way that you capture user input is quite brittle. While it will work fine as long as the user knows they should only input integers, it's never safe to assume that users will provide valid input:
What would you like to do?:  hello
Exception in thread &quot;main&quot; java.util.InputMismatchException

We first need to handle this InputMismatchException for cases where the user enters an invalid value, by using try-catch:
try {
    choice = cai.nextInt();
} catch (InputMismatchException exc) {
    System.out.println(&quot;Invalid input&quot;);
}

This is not quite right yet, though; even though it handles the exception and prevents a program crash, we need to not leave this block until we actually have input we can use. So let's introduce a validation condition and a while loop:
int choice = 0;
boolean inputIsInteger = false;
while (!inputIsInteger) {
    System.out.print(&quot;\nWhat would you like to do?: &quot;);
    try {
        choice = cai.nextInt();
        inputIsInteger = true;
    } catch (InputMismatchException exc) {
        System.out.println(&quot;Input must be an integer.&quot;);
        cai.next();
    }
}

Now, that works pretty well:
What would you like to do?:  hello
Input must be an integer.

What would you like to do?:  1

Addition

You may think: &quot;But, that seems like a lot of code to handle one single user input!&quot;
And you would be right! Fortunately, Scanner has a built-in method hasNextInt() that does this in a much simpler way:
System.out.print(&quot;\nWhat would you like to do?: &quot;);
while (!cai.hasNextInt()) {
    System.out.println(&quot;Input must be an integer.&quot;);
    cai.nextLine();
    System.out.print(&quot;\nTry again: &quot;);
}
int choice = cai.nextInt();

This way our Scanner will keep looping until it finds a valid int in the input buffer, making it safe to then call nextInt().

So far, so good. Now, I noticed that you are needing to get integer inputs everywhere in your code... We could save us a lot of copying and pasting of the above code by making a method that does this for us:
private static int getIntInput(Scanner sc) {
    while (!sc.hasNextInt()) {
        System.out.println(&quot;Input must be an integer.&quot;);
        sc.nextLine();
        System.out.print(&quot;\nTry again: &quot;);
    }
    return sc.nextInt();
}

Then, each time we need to scan for an int, we just call it with an instance of Scanner:
System.out.print(&quot;\nWhat would you like to do?: &quot;);
int choice = getIntInput(cai);


You should also validate that the input is usable according to your program logic, for instance that the choice is a valid choice (i.e. 1 - 4) otherwise ask the user for valid input. This should be easily done using another while loop or some similar construct.
boolean isValidChoice = false;
int choice = 0;
while (!isValidChoice) {
    System.out.print(&quot;\nWhat would you like to do?: &quot;);
    choice = getIntInput(cai);
    if (choice &gt; 0 &amp;&amp; choice &lt;= 4) {
        isValidChoice = true;
    } else {
        System.out.println(&quot;\nChoose an option from 1 to 4: &quot;);
    }
}

if (choice == 1){
    addition();
}
// etc...


Other things
Here are some other concerns &amp; suggested improvements on the code.

Consider moving your menu selection out of main and into its own method, like calculatorMainMenu() and call that when you need it.

The (One / Two) calculation in your division() method can result in ArithmeticException due to possible division-by-zero error. You should validate Two to make sure that 0 is never acceptable as input.

Consider using a switch statement instead of a lot of if-else for things like your menu, where you're just comparing a variable against some constants.

Naming an instance of Scanner as cai is pretty odd. Writing something like scanner or sc for short is much more commonplace.

The names One and Two are also a bit odd. Something like num1 and num2 would be better, I think, to make it simple and clear that there's no particular significance to them other than the order in which they appear.

&quot;Caluclator&quot; should be spelled &quot;Calculator&quot;

Only the result of an addition is called &quot;sum&quot;. To be correct, you should use &quot;difference&quot; for subtraction, &quot;product&quot; for multiplication, and &quot;quotient&quot; for division.