我试图将while循环转换为for循环,但是每当转换它时,代码都不会像while循环那样完成
import java.util.Scanner;
public class Lab15cPowerOfBases
{
public static void main(String[] args)
{
int base, base2, base_max, power, power2;
Scanner num_value = new Scanner(System.in);
System.out.println("Please enter a base number from 2-12:");
base_max = num_value.nextInt();
System.out.println("Please enter a power number from 2-10:");
power = num_value.nextInt();
power2 = 0;
base2 = 1;
base = 1;
while(power2 == 0 && base <= base_max)
{
System.out.print(base + "^0=1" + "\t ");
power2++;
for( ; power2 <= power ; power2++)
{
base2*=base;
System.out.print(base + "^" + power2 + "=" + base2 + "\t ");
}
System.out.print("\n");
base= base + 1;
power2 = 0;
base2 = 1;
}
}
}