In: Computer Science
(This is for java)
I need to rewrite this code that uses a while loop.
public class Practice6 {
public static void main (String [] args)
{
int sum = 2, i=2;
do {
sum *= 6;
i++;
} while (i < 20);
System.out.println("Total is: " + sum);
}
The Program code in while Loop is :
//Java Programming Using while
loop
public class Practice6
{
public static void main(String[] args)
{
int sum = 2, i=2;
while (i < 20)
{
sum *= 6;
i++;
}
System.out.println("Total is: " +
sum);
}
}