![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#31 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
My suggestion for your next step would be to enhance the user interface. Have the user enter a number followed by (or appended with) the appropriate letter. For example, 100C or 100 C would be converted to the appropriate fahrenheit value. One thing to remember with users is that they are careless, make typos, go to sleep with their head on the keyboard, or maliciously try to break your program. Input validation is therefore very important for robust programming.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#32 | |
|
Programmer
Join Date: Jun 2005
Posts: 34
Rep Power: 0
![]() |
Quote:
It's true that the temperature and the letter for either Fahrenheit or Celsius conversion should be entered on the same line. Well, it should be possible to enter the number and the letter on the same line. I'm not sure how I could accomplish that but I'll see what I can do. Thanks |
|
|
|
|
|
|
#33 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I suggest you try it out - if you can accomplish it, you'll have learnt a lot. Basically, what you need to do is read the whole thing into a string, check the last character (which should be 'C' or 'F') - you can use charAt for this, and use a function that converts a string to a floating-point number to decipher the rest. I don't know Java, so I can't point you in the direction of a specific function, but someone else should be able to give you a hand.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|