• Post Reply Bookmark Topic Watch Topic
  • New Topic

Casting  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was given the question:
Write a class SimpleMath that asks the user to input 2 integer values and then computes +, -, *, /, % and displays them with appropriate text.  For the /, you will have to cast the integer values into double to ensure proper results.


I was able to create the following code:

I learn best when I see the answer, then look at how it works and then apply it to other things.


 
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Have you tried to find an immediate answer here? What difficulties you were encountered after looked to an example you were expecting?
 
George W. Willis
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:Welcome to the Ranch.

Have you tried to find an immediate answer here? What difficulties you were encountered after looked to an example you were expecting?

I read it and I tried upcasting because integer to double is being more specific, but I still have no idea what to do.
 
Liutauras Vilda
Sheriff
Posts: 4931
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
George W. Willis wrote:I read it and I tried upcasting
Please show us what have you tried for that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!