Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int months, counter = 1 ;
- String str = "", str2;
- double bills;
- double bills2=0;
- double total = 0, ave = 0;
- months = Integer.parseInt(JOptionPane.showInputDialog("Enter number of months of electricty bill"));
- while (counter<=months)
- {
- bills = Double.parseDouble(JOptionPane.showInputDialog("Enter electricity bill for the month " + counter));
- bills2 = bills + bills2;
- str += str2 = "Month: " + counter+ " = " + bills + "\n";
- counter++;
- }
- ave = bills2/counter;
- JOptionPane.showMessageDialog(null, str + "\n The total electricity bill is " + String.format("%.2f", bills2) + "\n The average is " + String.format("%.2f", ave));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement