Convert the MileConversions program to an interactive application. Instead of assigning a value to the miles variable, accept it from the user as input.
class MileConversionsInteractive
{
public static void main(String[] args) {
// Modify the code below
final double INCHES_IN_MILE = 63360;
final double FEET_IN_MILE = 5280;
final double YARDS_IN_MILE = 1760;
double miles = 4;
double in, ft, yds;
in = miles * INCHES_IN_MILE;
ft = miles * FEET_IN_MILE;
yds = miles * YARDS_IN_MILE;
System.out.println(miles + " miles is " + in +
" inches, or " + ft + " feet, or " +
yds + " yards");
}
}
Answers
Answered by
0
Answer:
class MileConversionsInteractive
{
public static void main(String[] args) {
Scanner s = new Scanner(System.in)
double mile = s.nextInt(); // here we are taking inputs from the user
final double INCHES_IN_MILE = 63360;
final double FEET_IN_MILE = 5280;
final double YARDS_IN_MILE = 1760;
double in, ft, yds;
in = miles * INCHES_IN_MILE;
ft = miles * FEET_IN_MILE;
yds = miles * YARDS_IN_MILE;
System.out.println(miles + " miles is " + in +
" inches, or " + ft + " feet, or " +
yds + " yards");
}
}
Similar questions