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

Discussion in 'Java' started by glj625, Nov 13, 2019.

  1. glj625

    glj625

    Joined:
    Nov 13, 2019
    Messages:
    1
    Likes Received:
    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.
     

    Attached Files:

    glj625, Nov 13, 2019
    #1
    1. Advertisements

  2. glj625

    John Joe

    Joined:
    Apr 25, 2017
    Messages:
    124
    Likes Received:
    15
    Location:
    Malaysia
    What is your expected output? I key in a negative value, but it doesn't throw any exceptions.
    Can you write a sample output ?
     
    John Joe, Nov 13, 2019
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.