# simple calculation code

• October 7th, 2013, 11:30 AM
dokunbam
simple calculation code
am trying to make this code work to do simple calculation
Code Java:

```  package inputuserifstatement; import javax.swing.JOptionPane; public class Inputboxesifstatement {   public static void main(String[] args) { double firstnumber; firstnumber = JOptionPane.showInputDialog("Enter Number");   double secondnumber; secondnumber = JOptionPane.showInputDialog ("Enter Second Number");   double answer; answer = firstnumber + secondnumber;   JOptionPane.showMessageDialog(null, answer); System.exit(0);```
• October 7th, 2013, 11:34 AM
tools
Re: simple calculation code
You have an illegal whitespace and you can't just convert at string to double like you try to
• October 7th, 2013, 11:46 AM
dokunbam
Re: simple calculation code
ok so what should i do
am a still a learner, just started 3 days ago
• October 7th, 2013, 11:50 AM
newbie
Re: simple calculation code
You need to convert the String into a double value. This is easily accomplished using the following method: parseDouble();
• October 7th, 2013, 12:55 PM
dokunbam
Re: simple calculation code
some thing is wrong here too
i will not give up
i hope some day i will give answer to people's problem

Code Java:

``` public static void main(String[] args) { // TODO code application logic here   int user = 18; if(user < 16) { System.out.println("user is underage"); } else if (user >= 18 && < 50) { System.out.println("Required Age"); } else {System.out.println("not of required age");```
• October 7th, 2013, 02:21 PM
newbie
Re: simple calculation code
else if (user >= 18 && < 50) should be else if (user >= 18 && user < 50). This is a typical rookie mistake, as it does make sense. However, each side of the || and && operators need to evaluate to either true or false independently.
• October 8th, 2013, 06:10 AM
dokunbam
Re: simple calculation code
Guys help me out on this too

Code java:

``` public static void main(String[] args) { // TODO code application logic here int[][]aryNums; aryNums = new int [2][6]; aryNums[0][0] = 10; aryNums[1][0] = 60; aryNums[0][1] = 20; aryNums[1][1] = 50; aryNums[0][2] = 30; aryNums[1][2] = 40; aryNums[0][3] = 40; aryNums[1][3] = 30; aryNums[0][4] = 50; aryNums[1][4] = 20; aryNums[0][5] = 60; aryNums[1][5] = 10;   { System.out.println(aryNums[][] + " "); } System.out.println(" ");```
• October 8th, 2013, 06:55 AM
macko
Re: simple calculation code
I have already replied to the thread you posted the exact question on

http://www.javaprogrammingforums.com...tml#post125514