I'm trying to write a simple Calculator program. After I wrote the 4 methods for doing the math I wanted the main method offer the user to choose one of the 4 operations by typing a number.
import java.util.Scanner;
public class Calculator {
public static void main (String [] args) {
System.out.println("Select Operation. 1=Addition, 2=Substraction, 3=Multiplication, 4=Divison");
int inInt1;
int inInt2;
int inInt3;
int inInt4;
Scanner in = new Scanner (System.in);
inInt1 = in.nextInt();
inInt2 = in.nextInt();
inInt3 = in.nextInt();
inInt4 = in.nextInt();
if (inInt1 == 1) {
addition(String [] args );
}
}
public static void addition (String[] args){
int inInt1;
int inInt2;
int outInt;
Scanner in = new Scanner(System.in);
inInt1 = in.nextInt();
inInt2 = in.nextInt();
outInt = inInt1 + inInt2;
System.out.println(outInt);
}
I don't really know if anything there is redundant. The error is
Calculator.java:21:26: error: '.class' expected
addition(String [] ).main;
Calculator.java:19:30: error: ';' expected
addition(String [] args);
Aucun commentaire:
Enregistrer un commentaire