16 lines
655 B
Java
16 lines
655 B
Java
package tech.nevets;
|
|
|
|
import javax.swing.*;
|
|
|
|
public class STMileageD {
|
|
public static void main(String[] args) {
|
|
JOptionPane.showMessageDialog(null, "This program will calculate mileage");
|
|
int miles = Integer.parseInt(JOptionPane.showInputDialog("Enter the miles driven"));
|
|
int gallons = Integer.parseInt(JOptionPane.showInputDialog("Enter the gallons used"));
|
|
float mpg = (float) miles / (float) gallons;
|
|
JOptionPane.showMessageDialog(null, mpg + " miles per gallon");
|
|
String mpgFormatted = String.format("%.2f miles per gallon", mpg);
|
|
JOptionPane.showMessageDialog(null, mpgFormatted);
|
|
}
|
|
}
|