Modify the following method to use a for loop instead of the while loop:
public static void sumTo()
{
int n; int total = 0; int count = 0;
String output = “”;
String str;
str = JOptionPane.showInputDialog(“Give me a number to sum to: “);
n = Integer.parseInt(str);
while (count ,= n)
{
total = total + count;
output += count +”:\t” + total + “\n”;
count = count + 1;
}
JOptionPane.showMessageDialog(null, output);
}
1
Expert's answer
2018-05-03T03:33:10-0400
Dear SHEHZAAD, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment