ok.. i have solved many problems by myself but wtf, more errors... i dont get this $hit... anyway this some code for a calculator program (in good tradition i called it Kalculator
)
i recieve the following error at the //********* (near if/else's at result=)
**incompatible types- found int but expected java.lang.String**
how can i fix this? thanks in adcance, sincerly
import java.awt.*;
import javax.swing.*;
public class Kalculator extends JFrame
{
public Kalculator()
{
super("Kalculator");
Container c= getContentPane();
c.setBackground (Color.white);
c.setLayout (new FlowLayout());
c.add (new JLabel ("Kal"));
}
public static void main (String []args)
{Kalculator window= new Kalculator();
String temp,result;
EasyReader Read= new EasyReader();
System.out.print ("Select your desired operation (1,2,3,4) -->");
temp= Read.readLine();
int menuChoice= Integer.parseInt(temp);
System.out.print ("Enter the first integer:");
temp= Read.readLine();
int num1= Integer.parseInt(temp);
System.out.print ("Enter second integer:");
temp= Read.readLine();
int num2= Integer.parseInt(temp);
if (menuChoice==1)
result=num1+num2; //here is my error
if (menuChoice==2)
result=num1-num2;
if (menuChoice==3)
result=num1*num2;
if (menuChoice==4)
result=num1/num2;
else
System.out.print ("Incorrect entry. Please try again with one of the following options:/n"+
"1 adds two numbers/n"+ "2 subtracts two numbers/n"+ "3 multiplies two numbers/n"+ "4 divides two numbers");
System.out.print ("The result is"+result);
window.setSize(900, 400);
window.show();
}
}