Im learning Java and am having problems with my code.
Im learning Java and am having problems with my code. I used this
code in C and it works but converting it to Java is giving me errors and I cant understand why its telling my my expressions aren’t recognized. I am returning 4 errors in lines 10, 14, 20, 29. Where am I going wrong and how?
import java.util.Scanner;
public class AverageQuizScore {
/**
* @param args
*/
public static void main(String[] args) {
// variable declarations:
char name [100];
float sum, grade, average;
int students, exams, nr;
printf(“How many students do you want to enter?\n”);
scanf(“%d”, &nr);
for (students = 0; students < nr ; students++) {
printf (“Enter 3 grades and student name: “);
sum = 0;
for (exams = 0; exams < 3; exams++) {
// float uses %f, double uses %lf
scanf (“%f”, &grade);
sum = sum + grade;
} // end for each exam
average = sum / 3;
scanf (“%s”, name);
printf (“Average for %s is %.2f\n”, name, average);
} // end for each student
printf(“… Bye …\n”);
return 0;
} //end main