I am a new student to Jaca Programming. I need help finding out where I am going wrong with my code.

I am trying to have a user input 2 numbers and then have the input the calculation method of their choce. Add, subtact,multiply,divide.

package javaapplication10;


import java.util.Scanner;
/**
 *
 * @author cgigandet
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args, {            


     Scanner input = new Scanner(System.in);    


      boolean IsValid = true;

                while(IsValid)
                {


Scanner.out.println ("Enter larger number first : "); //request the input of the first interger
         int num1 = input.nextInt();//request the input of the first interger


System.out.println ("Enter second number: "); //request the input of the second interger
        int num2=Scanner.String.next();//request the input of the first interger

        {        


        System.out.println("please choose a calculation method selecting menu item" +
                   " 1 - 5");
           int calculation = input.nextInt();
           if (calculation >=5)

          {
               System.out.println("Exit Program");
               IsValid = false;
           }
           else{
                switch(calculation)
                {
                    case(1):
                    System.out.println("you entered add.");
                    System.out.println ("answer = ; " + (num1 + num2));
                    break;

                    case (2):
                    System.out.println("you entered subtract.");
                    System.out.println ("answer = ; " + (num1 + num2));
                    break;

                    case (3):
                      System.out.println("you entered multiply.");
                      System.out.println ("answer" + (num1 * num2));
                      break;
                    case (4):
                      System.out.println("you entered divide.");
                      System.out.println ("answer " + (num1 / num2));
                      break;
                    case (5) :
                       default:System.out.println("Exit.");
                        System.out.println("Exit.");
                        break;



}
           }
                }
                }

Edited 3 Years Ago by Dani: Formatting fixed

This line should be giving you a problem:

Scanner.out.println ("Enter larger number first : "); //request the input of the first interger

Change Scanner to System.
Also use code tags when posting code. Thanks
Also when doing switch cases there is no need to enclose the case number in parentheses.

Edited 7 Years Ago by Grn Xtrm: n/a

This article has been dead for over six months. Start a new discussion instead.