I need to be able to get this code to read negative and decimal numbers....

Joined
Nov 13, 2019
Messages
1
Reaction score
0
Hello! For my computer science class, I need to be able to get my code to read negative numbers AND decimal numbers.... The professor showed us how to do this, and said for an assignment that if we can get it to read negative and decimal numbers, we would get extra points. Attached is the code, and yes I am well aware that System.in.read is horrible, and there is main code as well as other sub routines within this code, but the main area of focus is the sub routine labeled "readNumbers", and that is what needs to read the negative and decimal numbers... Also, if there is anything else you guys think I should change in the other programs, let me know. I'd love to hear some feedback and understand new ways to do things. Unfortunately, I cannot change System.in.read() for now, as my professor wants us to use it that way for now.
 

Attachments

  • DisplayNumbers.txt
    2 KB · Views: 133
Joined
Apr 25, 2017
Messages
260
Reaction score
36
What is your expected output? I key in a negative value, but it doesn't throw any exceptions.
Can you write a sample output ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,056
Messages
2,570,440
Members
47,101
Latest member
DoloresHol

Latest Threads

Top