Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

[Confusion] A Java Question

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.?
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the code you tried, the exception stack trace if any.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this Code, but the error is again: Incompatible Types
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 75682
354
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 75682
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
 
Ranch Hand
Posts: 115
11
IntelliJ IDE Clojure Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic