• Post Reply Bookmark Topic Watch Topic
  • New Topic

output comes twice  RSS feed

 
Ahmed mood
Greenhorn
Posts: 2
Android Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


please i need help with the previous code as in the output, asking for the name, age and subjects marks comes twice.
i am sure it is due to the extension i am doing.
i have tried to use final keyword on the method to prevent the extension but no use .

altough if it is possible, i am trying to use the Exception in case input marks is more than 90 it should show an error.

can any one help please ?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmed mood wrote:
please i need help with the previous code as in the output, asking for the name, age and subjects marks comes twice.


Well, simply, you are calling the sum() method twice. Once from the main() method. And once from the per1() method.

Henry
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and welcome to the Ranch

Don't use floats; if you need floating‑point numbers use doubles instead.
 
Ahmed mood
Greenhorn
Posts: 2
Android Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you soo much guys for the help.it works fine now.

but what about the exception?
Does anyone knows the way ?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmed mood wrote:but what about the exception?
Does anyone knows the way ?


No special magic trick here... ... If you need an exception thrown under a particular condition, then you simply need to check for the condition, and throw the exception.

Or are you asking for how to instantiate and throw an exception?

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!