• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

display method

 
Greenhorn
Posts: 3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am implementing  a program that converts a sum of money to a different currency.The amount of money to be converted ,and the exchange rate,are entered by the user.The program should have separate methods for:
obtaining the sum of money;
obtaining the exchange rate from the user;
making the conversion;
display the result
Am stuck on how am going to display the results with calling the method display(). Any help will be highly appreciated.

This is my program that i have been working on.



 
Sheriff
Posts: 13510
223
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to tell us more than just "I'm stuck."

Do you have specific questions? What exactly are you confused about?

And welcome to the Ranch!
 
Junilu Lacar
Sheriff
Posts: 13510
223
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can tell you that your code so far appears to be confused. For example, the usrInput() and exchange_rte() methods are essentially duplicates of each other. It doesn't matter that you use different names and have different intents for them, they both do essentially the same thing and therefore are duplicates.

Also, there is no need to create a Scanner object in those methods. You can create one Scanner in main and use it across your entire program. The Scanner variable in this case would be a static member variable.
 
Heseltine Tutu
Greenhorn
Posts: 3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:I can tell you that your code so far appears to be confused. For example, the usrInput() and exchange_rte() methods are essentially duplicates of each other. It doesn't matter that you use different names and have different intents for them, they both do essentially the same thing and therefore are duplicates.

Also, there is no need to create a Scanner object in those methods. You can create one Scanner in main and use it across your entire program. The Scanner variable in this case would be a static member variable.



thank you i will correct that.my question is how am i going to make the method display() to print out the results after a user enters the information prompted?





 
Ranch Hand
Posts: 125
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your display method is inside conversion method. This should not have compiled. So, I am assuming you just pasted the code incorrectly. For display method to print the result, your conversion method should return the result, and the main method should call display method with this result.
 
Heseltine Tutu
Greenhorn
Posts: 3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Salil Wadnerkar wrote:Your display method is inside conversion method. This should not have compiled. So, I am assuming you just pasted the code incorrectly. For display method to print the result, your conversion method should return the result, and the main method should call display method with this result.


I will work on that and see if it will compile in the mean time thank you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!