Solved

Calculate grade totals and average grades.

Posted on 2009-03-29
1
987 Views
Last Modified: 2012-05-06
This still will not compile because there is an error with the For Statement somewhere.  I am missing something and I'm not sure, obvious logic problem.  I'm looking through my book but the compilation error comes up and says that there is an error with the semi colon after gradeCounter, the "!" which is my sentinel, and the space after i++.  I don't understand.  Please point me in the right direction.  I'm really racking my brain; I'm a beginner programmer.
Thanks!!!
r/
Cliff
import java.util.Scanner;
 
public class AverageGrades {
 
public static void main(String[] args){
        
    scanner input = new Scanner ( System.in );
 
    int double grade;
    int double sum = 0;
    int double gradeCounter = 0;
    int double grade = 0;
 
    // read the number of grades
    System.out.println( "Enter the number of grades: ");
    grade = input.nextInt();
 
//calculate the total of all grades entered
      
    For ( gradeCounter = 1; grade != 0; i++ )
      
    // read grade from the user
    System.out.println( "Enter grade(s):");
    grade = input.nextInt();
     
    // add the grade to the sum, and add 1 to count
    sum = sum + grade;
   
    //calculate the average
 
    int double average = 0;
      
    average = (double) sum / gradeCounter;
    System.out.println( "The grade average is " + average );
    
       } // end Main
} // end Class

Open in new window

0
Comment
Question by:calbanese13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
basav_com earned 500 total points
ID: 24013450
As I said in my last post you need to change these:
    int double grade;
    int double sum = 0;
    int double gradeCounter = 0;
    int double grade = 0;


and For  it should be       ' for '       ---> java is case sensitive
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
difference between sorce folder and folder in eclipise 3 65
ejb entity bean example 2 59
collection output issue 9 96
Which is best Image Resizing Web service 11 42
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question