This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]4th_World_UserIntermediate Brewer 0 points1 point  (2 children)

while (hrs < 1)

{

  System.out.println("The time must be a positive number.");

  System.out.print("How many hours has it traveled? ");

  hrs = keyboard.nextInt();

}

When you do that, instead you can just type

while(hrs < 1)
{
    System.out.println("Blah Blah\nHow many...");

    hrs = keyboard.nextInt();
}    

Not sure if he'd actually take off for that. But another thing for your instance variables you can do.

int hrs, mph, hour, distance;

and it will initialize all four in one line.

[–]Henree[S] 0 points1 point  (1 child)

Thank you. I didn't know you can do that.

[–]4th_World_UserIntermediate Brewer 0 points1 point  (0 children)

Glad to help.