Question
For those who know Java: I have a code that calculates tuition at NHCC. I have a couple of issues I need help with: Every
For those who know Java: I have a code that calculates tuition at NHCC. I have a couple of issues I need help with:
Every time you type "2" for online courses on the first question in program, the next question asks how many credits you're taking but everytime you put a number it becomes an error in the program. Can someone please fix this?
And lastly, How can I put my logo right next "North Hennepin Community College" and make it reasonably really small. Can someone fix this?
Please make sure this program works with your changes.
Code:
import java.text.DecimalFormat; import javax.swing.ImageIcon; import javax.swing.JOptionPane;
public class TuitionCost{
public static void main(String[] args) { int costCredits; int student; String input; double a;
DecimalFormat dollar = new DecimalFormat("#,##0.00"); final ImageIcon icon= new ImageIcon(TuitionCost.class.getResource("logo.png")); JOptionPane.showMessageDialog(null, "North Hennepin Community College", "Tuition Costs at NHCC", JOptionPane.INFORMATION_MESSAGE); String[] options={"1","2"};
input = (String) JOptionPane.showInputDialog(null,"Are you taking: 1 - on-campus and/or hybrid courses 2 - online courses Please enter 1 or 2:","Input", JOptionPane.QUESTION_MESSAGE, icon, options, icon); double[] rates = {184.17,193.85}; student = Integer.parseInt(input);
if(student > 0 && student < 4){ input = JOptionPane.showInputDialog(null, "How many credits are you taking?", JOptionPane.QUESTION_MESSAGE); costCredits = Integer.parseInt(input); if(costCredits != 0){ a = costCredits * rates[student]; float textBookCosts=(float)320.50; JOptionPane.showMessageDialog(null, dollar.format(costCredits) + " credits at $" + rates[student] + " per semester yields a tuition of $" + dollar.format(a)+" Textbooks cost=$"+textBookCosts); }else{ JOptionPane.showMessageDialog(null, "Credits cannot be zero.", "Invalid Input", JOptionPane.ERROR_MESSAGE); } System.exit(0); }else { JOptionPane.showMessageDialog(null, "You must enter a 1 or 2. Please Run the program again.", "Invalid Input", JOptionPane.ERROR_MESSAGE); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started