//File: Rate.java import CSLib.*; public class Rate { public static void main (String [] args) { //Input InputBox in = new InputBox(); in.setPrompt ("What is the term of the loan? (12, 24, 36, 48, or 60 months)"); int term = in.readInt(); OutputBox out = new OutputBox(); //Figure out the interest rate double rate = 0.0; /* if (term == 12 || term == 24) { rate = 0.9; } else if (term == 36) { rate = 2.9; } else if (term == 48) { rate = 4.9; } else if (term == 60) { rate = 6.9; } */ //alternative to if-else switch (term) { case 12 : case 24 : rate = 0.9; break; case 36 : rate = 2.9; break; case 48 : rate = 4.9; break; case 60 : rate = 6.9; break; default : out.println ("Must have term of 12, 24, 36, 48, or 60"); Timer.pause (5000L); System.exit (1); } //Output out.println ("With a term of " + term + " months, your interest rate is: " + rate + "%."); } }