-
-
Save Fahrek/92fcee8f835ee9b7daea2e31ccded421 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 java.text.DecimalFormat; | |
import javax.swing.JOptionPane; | |
public class TuitionCost { | |
public static void main(String[] args) { | |
int costHours; | |
int student; | |
String input; | |
double a; | |
DecimalFormat dollar = new DecimalFormat("#,##0.00"); | |
JOptionPane.showMessageDialog(null, "OCC Tuition Cost Calculation Program", "Tuition Costs at OCC", JOptionPane.INFORMATION_MESSAGE); | |
input = JOptionPane.showInputDialog(null, "Are you a:\n1 - College District Residents\n2 - Non-Residents of College District\n3 - Out-of-State and International Students\n\nPlease enter 1, 2 or 3:", "Input", JOptionPane.QUESTION_MESSAGE); | |
double[] rates = {76.40,139.10,195.15}; | |
student = Integer.parseInt(input); | |
if(student > 0 && student < 4){ | |
input = JOptionPane.showInputDialog(null, "How many credit hours are you taking?", JOptionPane.QUESTION_MESSAGE); | |
costHours = Integer.parseInt(input); | |
if(costHours != 0){ | |
a = costHours * rates[student]; | |
JOptionPane.showMessageDialog(null, dollar.format(costHours) + " hours at $" + rates[student] + " per hour yields a tuition of $" + dollar.format(a)); | |
}else{ | |
JOptionPane.showMessageDialog(null, "Credit hours cannot be zero.", "Invalid Input", JOptionPane.ERROR_MESSAGE); | |
} | |
System.exit(0); | |
}else { | |
JOptionPane.showMessageDialog(null, "You must enter a 1, 2, or 3.\nPlease Run the program again.", "Invalid Input", JOptionPane.ERROR_MESSAGE); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment