This code will print out 1 user and total one at a time in a dialog box 3 times. Now the code is how is suppose to be. Now how would I use this same code to show in the same dialog box but all 3 names and total in one dialog box?
Here is a quick output of how it should be. But not sure how to do it.
Thanks
mport javax.swing.JOptionPane; public class testing { public static void main(String[] args){ Scanner input = new Scanner(System.in); String name; int kilowattsUsed; double total; int counter = 1; while (counter < 4){ System.out.println("Enter name."); name = input.next(); System.out.println("How much kilowatts used?"); kilowattsUsed = input.nextInt(); total = kilowattsUsed *.056; counter = counter + 1; String message = String.format("%s $%.02f",name,total); JOptionPane.showMessageDialog(null,message); } } }