For a school project, I am trying to make a program that gets user input and finds the factorial of the input. I wrote this bit of code and got tons of errors. Help, anybody?
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.*;
class TestFactorial {
public int x = 6;
public int z = 0;
public boolean xiszero = false;
for (public int x > 0) {
z = (x*x-1);
x--;
}
for (public int x = 0) {
public boolean xiszero = true;
break;
}
for (public boolean xiszero = true) {
System.out.println(z)
}
}
Errors:
Main.java:10: illegal start of type
for (public int x > 0) {
^
Main.java:10: modifier public not allowed here
for (public int x > 0) {
^
Main.java:10: ')' expected
for (public int x > 0) {
^
Main.java:10: illegal start of type
for (public int x > 0) {
^
Main.java:10: <identifier> expected
for (public int x > 0) {
^
Main.java:10: ';' expected
for (public int x > 0) {
^
Main.java:11: <identifier> expected
z = (x*x-1);
^
Main.java:12: <identifier> expected
x--;
^
Main.java:14: class, interface, or enum expected
for (public int x = 0) {
^
Main.java:14: class, interface, or enum expected
for (public int x = 0) {
^
Main.java:15: class, interface, or enum expected
public boolean xiszero = true;
^
Main.java:16: class, interface, or enum expected
break;
^
Main.java:17: class, interface, or enum expected
}
^
Main.java:18: class, interface, or enum expected
for (public boolean xiszero = true) {
^