Created
December 2, 2016 19:26
-
-
Save WesJD/b5629b23d629d0619f8145e27ada33b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.JOptionPane; | |
public class CarRental { | |
private CarRental() { | |
final String make = JOptionPane.showInputDialog("What is the car make?"); | |
final String model = JOptionPane.showInputDialog("What is the car model?"); | |
final String licensePlate = JOptionPane.showInputDialog("What is the license plate value?"); | |
final int digits = Integer.parseInt(licensePlate.substring(4)); | |
int charTotal = 0; | |
for(char c : licensePlate.substring(0, 3).toCharArray()) charTotal += c; | |
final int sum = digits + charTotal; | |
final char letter = (char) ('A' + (sum % 26)); | |
JOptionPane.showMessageDialog(null, | |
"Make = " + make + "\nModel = " + model + "\n" + licensePlate + " = " + letter + "" + sum); | |
} | |
public static void main(String[] args) { | |
new CarRental(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment