...
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
...
Last edited by Count10101; June 8th, 2019 at 06:38 AM.
Also posted at https://www.dreamincode.net/forums/t...otalminutes-w/
And https://coderanch.com/t/710865/java/pull-input-var
Be sure to notify all sites when crossposting questions.
http://www.javaprogrammingforums.com...s-posting.html
If you don't understand my answer, don't ignore it, ask a question.
...
Last edited by Count10101; June 8th, 2019 at 06:38 AM.
Why did you delete the code?
For anyone interested, here is the code:
import javax.swing.JOptionPane; public class CellPhoneBill { public static int accountNum, dayMinutes, nightMinutes, totalMinutes, acctCall; public static char serviceCode, serviceCall; public static double amountDue; public static String outputStr, acctStr, serviceStr; public static void main(String[] args) { getAccountNum(accountNum); getServiceCode(serviceCode); serviceSwitch(serviceCode); System.exit(0); } public static double calculateRegBill(int a) { amountDue = 10; if (a > 50) amountDue = 10 + (a - 50) * .2; return amountDue; } public static double calculatePremBill(int a, int b) { double dayCost = 0, nightCost = 0; if (a > 75) dayCost = (a - 75) * .1; if (b > 100) nightCost = (b - 100) * .05; amountDue = 25 + (nightCost + dayCost); return amountDue; } public static int getAccountNum(int a) { a = Integer.parseInt(JOptionPane.showInputDialog("Enter account number")); accountNum = a; return accountNum; } public static char getServiceCode(char b) { b = JOptionPane.showInputDialog("Enter service code").charAt(0); serviceCode = b; return serviceCode; } public static void serviceSwitch(char a) { switch (a) { case 'r': case 'R': amountDue = calculateRegBill(Integer.parseInt(JOptionPane.showInputDialog("Enter amount of " + " minutes used in billing period"))); outputStr = "Account Num: " + accountNum + "\n Account Type" + ": Regular" + "\nAccount Minutes Used: " + totalMinutes + "\nAmount Due: $" + String.format("%.2f", amountDue); JOptionPane.showMessageDialog(null, outputStr, "Account" + " Information", JOptionPane.INFORMATION_MESSAGE); break; case 'p': case 'P': dayMinutes = Integer.parseInt(JOptionPane.showInputDialog("Enter amount" + "of minutes used between 6:00 a.m. to 6:00 p.m.")); nightMinutes = Integer.parseInt(JOptionPane.showInputDialog("Enter amount" + "of minutes used between 6:00 p.m. to 6:00 a.m.")); amountDue = calculatePremBill(dayMinutes, nightMinutes); outputStr = "Account Num: " + accountNum + "\n Account Type" + ": Premium" + "\nAccount Minutes Used: " + totalMinutes + "\nAmount Due: $" + String.format("%.2f", amountDue); JOptionPane.showMessageDialog(null, outputStr, "Account" + " Information", JOptionPane.INFORMATION_MESSAGE); break; default: JOptionPane.showMessageDialog(null, "Invalid Account type", "Account Information", JOptionPane.INFORMATION_MESSAGE); } } }
If you don't understand my answer, don't ignore it, ask a question.
John Joe (June 9th, 2019)