posted 18 years ago
it does not work
may be i have aproblem with my program
here is the program
_______________________
import javax.swing.*;
public class Calculator
{
public static void main(String[]args)
{
while(true)
{
System.out.println("Enter (1) for addition");
System.out.println("Enter (2) for substraction");
System.out.println("Enter (3) for multiplication");
System.out.println("Enter (4) for division");
System.out.println("Enter (5) for mod");
System.out.println("Enter (6) for binary");
System.out.println("Enter (7) for exit");
}
int choice=Integer.parseInt(JOptionPane.showInputDialog("Enter your choice here"));
if (choice==7)
{
System.exit(0);
}
switch (choice)
{
case 0:
choice=1;
String Choose= String.valueOf(choice);
if ((Choose.equals("1"))||(Choose.equals("+"))||(Choose.equals("add")))
{
choice=1;
String Choose= String.valueOf(choice);
double value=0;
double value1=Double.parseDouble(JOptionPane.showInputDialog("Enter the nomber you want to calculate"));
double value2=Double.parseDouble(JOptionPane.showInputDialog("Enter the nomber you want to calculate"));
value=value1+value2;
double sum=0;
double temp=0;
while (!Choose.equals("="))
{
temp=value;
sum+=temp;
Choose=JOptionPane.showInputDialog("Enter your choice here");
}
}
else
{
System.out.println(sum);
System.exit(0);
}
}
}
}
[ February 04, 2006: Message edited by: tayy abdelqader ]
[ February 04, 2006: Message edited by: tayy abdelqader ]