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: 104
Ad

Advertisements

Joined
Apr 25, 2017
Messages
179
Reaction score
23
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

Top