Lost on the “for” Loop

Maybe I’m wrong, but it seems that you are asking for someone else to do your homework.If you want to get some effective help from the community you must show us a little effort in doing the homework yourself.
I assume that you are unable to start with your assignment so I give you some starting points:

  1. You can use a scanner to read the user input from the console; you can see from here an example of reading user input; please take also a look at the java api documentation (available here)
  2. You must decide if you want to read a String from the input and converting manually to a decimal number or if to read a decimal numer form the input; if you are learning java I suggest you to start using scanner.nextDouble and when the program rusn correctly to change it and tryi to parse the user input manually and giving the correct feedback if what the user entered is not a number
  3. your program should read an integer first (call it tripsNo for example) and then loop tripsNo times asking for each trip data

If you try to arrange the program by yourself using the prevoius points, then show us what you have done, I’m quite sure you’ll get some answer on the problems you are facing with the code.

Leave a Comment