Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Confusion] A Java Question

 
Lavneet Sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get three exam grades from the user and compute the average of the grades. Output the average of the three exams.

1. Use BufferedReader to get input from the user, and System.out to output the result.
2. Use JOptionPane to get input from the user and to output the result.

I'm confused. Because when I try Buffered Reader to accept Interget or float, it says, "Incompatible Types"

And the same for JOptionPane. Can somebody please help me out of this.?
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the code you tried, the exception stack trace if any.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we would require some effort from your part in providing us the details about the issue and also show us the code you are trying.
 
Lavneet Sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this Code, but the error is again: Incompatible Types
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should get some idea about Using JOptionPane, and also check out the JOptionPane API to see what the method showInputDialog returns
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raphael Onofre, please note what it says on the title page for this forum:
We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.
If Lavneet Sharma looks in the API documentation and finds the return type of the input dialogue is a Rhubarb object, he will remember for ever. If you simply give a complete answer, he might never learn anything.
Don’t be annoyed with me, but I am pulling rank and deleting your post for a day or two.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from the vague thread title: I am 99% certain that try-finally does not do what you think it does, and does not do what you want it to.
 
Raphael Onofre
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Raphael Onofre, please note what it says on the title page for this forum:
We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.
If Lavneet Sharma looks in the API documentation and finds the return type of the input dialogue is a Rhubarb object, he will remember for ever. If you simply give a complete answer, he might never learn anything.
Don’t be annoyed with me, but I am pulling rank and deleting your post for a day or two.


Sorry for the mistake ;[

 
Lavneet Sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Mohamed and Sherrif for your concern...
Actually, i made a little ammendment that i learnt from somewhere over the net. I did this:

int x;
x = Integer.parseInt( JOptionPane.ShowInputDialog("TEST");
 
Jason Bullers
Ranch Hand
Posts: 111
8
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I am 99% certain that try-finally does not do what you think it does, and does not do what you want it to.


That's the first thing I noticed when I saw the code snippet. It would be a good idea to explore that topic further, as well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic