Results 1 to 4 of 4

Thread: number checker?

  1. #1
    linc186 is offline Member
    Join Date
    Mar 2011
    Posts
    8
    Rep Power
    0

    Default number checker?

    I'm building a small cmd line java app that asks you for a distance to get to one place, and then how much time you want to get there. The program will then generate the speed needed to get there in that time. The program will also tell you if you must exceed 65 mph, and it will add five minutes to the time for every 100 miles you input. Say that you input 250 for the distance, the program should know that there is a total of ten minutes of rest stops. Now, I've written all of that except for the five minute rest stop part. How would I get the program to know that if I set the distance to 560, that per each 100 there is five minutes added to the time variable. So, there would be 25 minutes total in rest stops.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Use the division operator.

    Java Code:
    public class DvisionEg {
        public static void main(String[] args) {
            System.out.println("560/100 is " + 560 / 100);
        }
    }

  3. #3
    linc186 is offline Member
    Join Date
    Mar 2011
    Posts
    8
    Rep Power
    0

    Default

    that doesn't help; I'm not using Ints so that would return an odd decimal number. Also, even if i were doing Ints, if i were to do 500 /5 i would get 100, which i still wouldn't know what to do with. I need the program to know how many hundreds there are (e.g. there are five hundreds in 500) and then add five minutes to the time variable for each 100

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. isbn checker
    By jingliu316 in forum New To Java
    Replies: 2
    Last Post: 10-27-2010, 08:31 PM
  2. Spell Checker in Swing
    By dhaivat in forum New To Java
    Replies: 2
    Last Post: 07-01-2010, 06:08 PM
  3. Printing the Number of Times a Number in a Range Shows up
    By space4rent00 in forum New To Java
    Replies: 1
    Last Post: 02-05-2010, 11:42 PM
  4. Grammar Checker
    By zaz_rin in forum New To Java
    Replies: 1
    Last Post: 07-19-2009, 03:01 PM
  5. ISBN Checker
    By blobs86 in forum New To Java
    Replies: 1
    Last Post: 03-24-2009, 12:07 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •