You are viewing our Forum Archives. To view or take place in current topics click here.
Was this a good calculator for a newbie?
Yes
0.00% (0 votes)
0.00% (0 votes)
No
0.00% (0 votes)
0.00% (0 votes)
Needs improvment
0.00% (0 votes)
0.00% (0 votes)
Total Votes: 0
Rate my Calculator
Posted:
Rate my CalculatorPosted:
Status: Offline
Joined: Jul 15, 201113Year Member
Posts: 16
Reputation Power: 0
Status: Offline
Joined: Jul 15, 201113Year Member
Posts: 16
Reputation Power: 0
ok so i just started java on monday and i have made a calculator please rate it 1-10
[spoiler]double number2;
char opsymbol = ' ';
JOptionPane.showMessageDialog(null, "Welcome to Alex's Calculator", "Calculator");
JOperationpane.showMessageDialog(null," ")
number1 = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter your first number"));
String operation = JOptionPane.showInputDialog(null, "Choose your operation \nAdd, Subtract, Multiply, or Divide");
number2 = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter your second number"));
double result = 0;
if (operation.equalsIgnoreCase("Add")){
result = number1 + number2;
opsymbol = '+';
}
else if (operation.equalsIgnoreCase("Subtract")){
result = number1 - number2;
opsymbol = '-';
}
else if (operation.equalsIgnoreCase("Divide")){
result = number1 / number2;
opsymbol = '/';
}
else if (operation.equalsIgnoreCase("Multiply")){
result = number1 * number2;
opsymbol = '*';
}
JOptionPane.showMessageDialog(null, "Result: " + number1 + opsymbol + " " + number2 + " = " + result);
}
}
[/spoiler]
[spoiler]double number2;
char opsymbol = ' ';
JOptionPane.showMessageDialog(null, "Welcome to Alex's Calculator", "Calculator");
JOperationpane.showMessageDialog(null," ")
number1 = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter your first number"));
String operation = JOptionPane.showInputDialog(null, "Choose your operation \nAdd, Subtract, Multiply, or Divide");
number2 = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter your second number"));
double result = 0;
if (operation.equalsIgnoreCase("Add")){
result = number1 + number2;
opsymbol = '+';
}
else if (operation.equalsIgnoreCase("Subtract")){
result = number1 - number2;
opsymbol = '-';
}
else if (operation.equalsIgnoreCase("Divide")){
result = number1 / number2;
opsymbol = '/';
}
else if (operation.equalsIgnoreCase("Multiply")){
result = number1 * number2;
opsymbol = '*';
}
JOptionPane.showMessageDialog(null, "Result: " + number1 + opsymbol + " " + number2 + " = " + result);
}
}
[/spoiler]
#2. Posted:
Status: Offline
Joined: Jul 07, 201113Year Member
Posts: 643
Reputation Power: 32
I dont get it...someone help me!
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Jul 15, 201113Year Member
Posts: 16
Reputation Power: 0
Status: Offline
Joined: Jul 15, 201113Year Member
Posts: 16
Reputation Power: 0
-Etna- wrote I dont get it...someone help me!
its java. i just coded it today lol
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.