accumulating totals in a loop
I have a prewritten java program to calculate the total of monthly bills. It should execute until the user enters "done" instead of bill type. After the user enters a bill type, he should be asked to enter the bill amount. I don't have a clue where to start. The prewritten program is as follows....
// MonthlyBills.java - This program calculates the total of your monthly bills.
// Input: Bill type and bill amount.
// Output: Prints the total of your monthly bills.
public class MonthlyBills
public static void main(String args)
String billType; // Description of bill.
String stringAmount; // String version of bill amount.
double billAmount; // Amount of the bill.
double sum = 0; // Accumulates sum of bills.
/* You should set up your loop to execute as long as the user
has not entered the word done. You can use these input and
output statements anywhere in your program. They are not in
any particular order.
// This input statement asks the user to enter a bill type or the word none.
billType = JOptionPane.showInputDialog("Enter bill type or the word done to quit.");
// This input statement asks your user to enter a bill amount.
stringAmount = JOptionPane.showInputDialog("Enter amount of bill");
// This statement converts the string version of the amount to a double.
billAmount = Double.parseDouble(stringAmount);
// This statement displays the sum of monthly bills.
System.out.println("Sum of monthly bills is $: " + sum);
// This statement causes the program to exit.
} // End of main() method.
} // End of MonthlyBills class.
Can anyone help complete this??
By draven2kg in forum VB Classic
Last Post: 08-25-2005, 03:00 PM
By Acceris in forum ASP.NET
Last Post: 06-30-2005, 03:31 PM
By salvinger in forum VB Classic
Last Post: 05-07-2005, 02:38 PM
By israfel in forum Database
Last Post: 03-10-2005, 04:33 PM
By Kent Hendrix in forum VB Classic
Last Post: 06-12-2000, 04:52 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL