I'm at the last part of my HW and it's to "Write out the square of the numbers starting with the user entered number, and up to 100." We have to use JOPtionPane for this problem. My for loop keeps getting errors, right now it says the String cannnot be converted to int.
I've tried converting i to an int by using int i = Integer.parseInt(); before the for loop but that didn't work and I didn't expect it to because it feels off.
String n = JOptionPane.showInputDialog("Enter a number 1-50");
int number = Integer.parseInt(n);
while(number<1 || number>50)
{
n = JOptionPane.showInputDialog("Bad number, Enter a number 1-50");
number = Integer.parseInt(n);
}
String filename = JOptionPane.showInputDialog("What is the name of the file?");
File f = new File(filename);
FileWriter fw = new FileWriter(filename);
PrintWriter pw = new PrintWriter(fw);
//PrintWriter file = new PrintWriter(filename)
//file.println(filename);
for(int i=n; i<=100; i*i)
nis still aString. You meant to usenumberi = i*i?i++.