Like the title suggests. I wrote the code and it works perfect with the while loop. But when i add in the other 2 loops they don't all 3 print. I do not understand why the other 2 loops will not print but Java throws no red flags. So i assume the code is written good enough for it to accept but not correctly. the code is as below
package thebrain;
import java.util.Scanner;
public class TheBrain {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the starting mile: ");
int start = keyboard.nextInt();
System.out.print("Enter the ending mile: ");
int end = keyboard.nextInt();
System.out.println();
while (start <= end){
double km = start * 1.609;
System.out.println("miles: " + (start) + ", " +
"kilometers: " + (km));
start += 1;
}
System.out.println();
do {
double km = start * 1.609;
start += 1;
System.out.println("miles: " + (start) + ", " +
"kilometers: " + (km));
} while (start <= end);
for (int s=start; s <= end; s++){
double km = start * 1.609;
System.out.println("miles: " + (s) + ", " +
"kilometers: " + (km));
}
}
}