public static void main(String[] args){
int passed = 0;
int failed = 0;
int N;
int grades;
{
while ( passed + failed ) < N {
if grades < 6 {
failed = failed + 1;
else
passed = passed + 1;
system.out.println passedperc = F/30*100
system.out.println failedperc = P/30*100
}
}
}
您的语法完全不正确。
这是一个很好的开始,尽管甚至不会声明passper,failedperc,F和P。此外,没有正确遵循变量约定。
public class TestClass {
public static void main(String[] args) {
int passed = 0;
int failed = 0;
int n = 0; //don't leave uninitialized and uncaptialize
int grades = 0; //same here
while ((passed + failed) < n) { //parens not correct
if (grades < 6) {//same here and missing brackets
failed = failed + 1; //can be changed to failed += 1;
} else
passed = passed + 1; //also can be changed using +=
}
//System print statements are wrong and variables are never declared or initialized
System.out.println(passedPerc = f / 30 * 100);//use camelCase don't use capital variables unless they are constants
System.out.println(failedPerc = p / 30 * 100);//same here
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句