package practiceapplication;
import static java.lang.Integer.parseInt;
class Practiceapplication{
static int calculate(String arguments[]){
int sum = 0;
if (arguments[0] == "+") //How do I use .equals() method at this point?
for(int x = 0; x < arguments.length; x++){
arguments = Integer.parseInt(arguments);
sum += arguments[x];
}
return sum;
if (arguments[0] == "*") {
for(int x =0; x < arguments.length; x++){
arguments =Integer.parseInt(arguments[]);
sum *= arguments[x];
}
} return sum;
if (arguments[0] == "-"){
for(int x = 0; x< arguments.length; x++){
arguments = Integer.parseInt(arguments);
sum -= arguments[x];
}
} return sum;
if(arguments[0] == "/"){
for(int x =0; x< arguments.length; x++){
arguments = Integer.parseInt(arguments);
sum /= arguments[x];
}
} return sum;
}
public static void main(String[] arguments){
if(arguments.length > 0)
Practiceapplication.calculate(arguments);
System.out.print("The answer is: " + sum); //Why was there an err at "sum"?
}
}
I just started learning java, so I don't know much. I apologize if I frustrate you, but hey, no one starts out from knowing everything.
Anyways, I think you get the idea what kind of application I was trying to make. I wanted to sum up everything I know into this thing, so it might look messy. Anyways, could someone tell me what's wrong, and possibly edit the parts where I made mistakes, please?
Thank you!