Click here to Skip to main content
15,908,776 members
Home / Discussions / Java
   

Java

 
QuestionAndroid Pin
programmervb.netc++8-Oct-10 7:15
programmervb.netc++8-Oct-10 7:15 
AnswerRe: Android Pin
DaveAuld8-Oct-10 8:52
professionalDaveAuld8-Oct-10 8:52 
QuestionOracle Driver problem Pin
itsh117-Oct-10 18:36
itsh117-Oct-10 18:36 
AnswerRe: Oracle Driver problem Pin
Richard MacCutchan7-Oct-10 22:30
mveRichard MacCutchan7-Oct-10 22:30 
AnswerRe: Oracle Driver problem Pin
David Skelly8-Oct-10 1:45
David Skelly8-Oct-10 1:45 
Questionhelp in j2me Pin
allaa2507-Oct-10 5:10
allaa2507-Oct-10 5:10 
AnswerRe: help in j2me Pin
Gerben Jongerius7-Oct-10 7:13
Gerben Jongerius7-Oct-10 7:13 
QuestionSimple Java Problem Pin
andyjin77776-Oct-10 17:55
andyjin77776-Oct-10 17:55 
import java.util.*;
import java.text.*;
import javax.swing.*;
class Lab4Part2{
public static void main (String[] args) {
String ex1;
double sum, F, a=0, b=0;
JFrame myWindow=new JFrame();
myWindow.setSize(500,400);
myWindow.setTitle("Calculator");
myWindow.setVisible(true);
myWindow.setLocation(600,200);
ex1=JOptionPane.showInputDialog(myWindow, "Enter an expression");
F=Double.parseDouble(ex1);
sum=(a+B);
JOptionPane.showMessageDialog(myWindow, "The sum is "+sum);
}
}

I need some help I keep getting an error when I try to run it on JGrasp. I have no clue what I'm doing wrong and for that matter I don't know what I have to do next if I am doing something wrong or not. However I'm trying to create a program where there are one input dialog that asking for the expression in "a+b" form like I would have to input "1+2" and then the second dialog would be a message giving the answer to that 1+2 which would show the message of 3. The program compiles fun and runs fine however whenever it asks me in the input dialog for an expression and I put "5+15" the message dialog shows an answer of 0.0 which is wrong as it should be 20 or 20.0 so basically at this point I don't know what I'm doing wrong or what I should do next as I am only a freshman in college and is only taking beginners object oriented programming using Java but anyways Thanks for helping. One last thing, I asked my teacher what I should do and she said I should use the substring and indexOf methods but she never told me how so I'm curious to what I should do and I need help with this too please and thank you.

PS. I tried Double.parseDouble method however I realized I can't parse more than one variable therefore that wouldn't work.
AnswerRe: Simple Java Problem Pin
Cedric Moonen6-Oct-10 20:33
Cedric Moonen6-Oct-10 20:33 
AnswerRe: Simple Java Problem [modified] Pin
SinghUlarity...8-Oct-10 5:54
SinghUlarity...8-Oct-10 5:54 
GeneralRe: Simple Java Problem Pin
SinghUlarity...8-Oct-10 6:00
SinghUlarity...8-Oct-10 6:00 
QuestionMessage Removed Pin
5-Oct-10 8:32
vivek8865-Oct-10 8:32 
AnswerRe: JAVA program to check please answer Pin
Dr.Walt Fair, PE5-Oct-10 11:19
professionalDr.Walt Fair, PE5-Oct-10 11:19 
GeneralRe: JAVA program to check please answer Pin
vivek8865-Oct-10 23:02
vivek8865-Oct-10 23:02 
AnswerRe: JAVA program to check please answer Pin
Richard MacCutchan5-Oct-10 11:35
mveRichard MacCutchan5-Oct-10 11:35 
GeneralRe: JAVA program to check please answer Pin
vivek8865-Oct-10 23:02
vivek8865-Oct-10 23:02 
GeneralRe: JAVA program to check please answer Pin
Richard MacCutchan5-Oct-10 23:06
mveRichard MacCutchan5-Oct-10 23:06 
GeneralRe: JAVA program to check please answer Pin
vivek8865-Oct-10 23:32
vivek8865-Oct-10 23:32 
GeneralRe: JAVA program to check please answer Pin
TorstenH.6-Oct-10 0:11
TorstenH.6-Oct-10 0:11 
GeneralRe: JAVA program to check please answer Pin
vivek8866-Oct-10 0:12
vivek8866-Oct-10 0:12 
GeneralRe: JAVA program to check please answer Pin
Richard MacCutchan6-Oct-10 0:20
mveRichard MacCutchan6-Oct-10 0:20 
GeneralRe: JAVA program to check please answer Pin
TorstenH.6-Oct-10 2:02
TorstenH.6-Oct-10 2:02 
GeneralRe: JAVA program to check please answer Pin
David Crow7-Oct-10 9:58
David Crow7-Oct-10 9:58 
AnswerRe: JAVA program to check please answer Pin
Luc Pattyn5-Oct-10 11:59
sitebuilderLuc Pattyn5-Oct-10 11:59 
GeneralRe: JAVA program to check please answer Pin
vivek8865-Oct-10 22:52
vivek8865-Oct-10 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.