Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.
// File: AverageGrades.java
// Name: Clifford Albanese
// Project 2
// Date: March 28, 2009
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
// File: AverageGrades.java
// Name: Clifford Albanese
// Project 2
// Date: March 28, 2009
import java.util.Scanner;
public class AverageGrades {
public static void main(String[] args){
Scanner input = new Scanner ( System.in );
double grade;
double sum = 0;
int gradeCounter = 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; gradeCounter++ ){
// 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
double average = 0;
average = (double) sum / gradeCounter;
System.out.println( "The grade average is " + average );
System.out.println( "Enter the number of grades: ");
grade = input.nextInt();
}
} // end Main
} // end Class
// File: AverageGrades.java
// Name: Clifford Albanese
// Project 2
// Date: March 28, 2009
import java.util.Scanner;
public class AverageGrades {
public static void main(String[] args){
Scanner input = new Scanner ( System.in );
double grade;
double sum = 0;
int gradeCounter = 0;
// read the number of grades
//System.out.println( "Enter the number of grades: ");
System.out.println( "Enter grade(s):");
grade = input.nextInt();
//calculate the total of all grades entered
while(grade!=0){
sum = sum + grade;
gradeCounter++;
// read grade from the user
System.out.println( "Enter grade. Type 0 to exit:");
grade = input.nextInt();
}
//calculate the average
double average = 0;
average = (double) sum / gradeCounter;
System.out.println( "The grade Sum is " + sum );
System.out.println( "The grade average is " + average );
} // end Main
} // end Class
import java.util.Scanner;
public class AverageGrades {
public static void main(String[] args){
Scanner input = new Scanner ( System.in );
double grade;
double sum = 0;
int gradeCounter = 0;
// Enter grades
System.out.println( "Enter grades (Grade of 0 causes average calculation: ");
grade = input.nextInt();
//calculate the total of all grades entered
for (gradeCounter = 1; grade != 0; gradeCounter++ ){
sum = sum + grade;
System.out.println( "Enter grades (Grade of 0 causes average calculation: ");
grade = input.nextInt();
}
gradeCounter--;
//calculate the average
double average = 0;
average = (double) sum / gradeCounter;
System.out.println( "Counter :" + gradeCounter );
System.out.println( "The grade sum is " + sum );
System.out.println( "The grade average is " + average );
} // end Main
} // end Class
import java.util.Scanner;
public class AverageGrades {
int count;
public double enterGrades () {
Scanner input = new Scanner ( System.in );
double grade = 0;
double sum = 0;
int gradeCounter = 0;
// Enter grades
System.out.println( "Enter grades (Grade of 0 causes average calculation: ");
grade = input.nextDouble();
//calculate the total of all grades entered
for (gradeCounter = 0; grade != 0; gradeCounter++ ){
sum = sum + grade;
System.out.println( "Enter grades (Grade of 0 causes average calculation: ");
grade = input.nextDouble();
}
count = gradeCounter;
return sum;
}
public double aveGrades (double sum ) {
//calculate the average
double average = 0;
average = (double) sum / count;
System.out.println( "The grade average is " + average );
return average;
}
public static void main(String[] args){
AverageGrades aGrades = new AverageGrades();
double sum = aGrades.enterGrades();
System.out.println("Sum : "+sum);
double average = aGrades.aveGrades(sum);
System.out.println("Count : "+aGrades.count);
System.out.println("Average : "+average);
} // end Main
} // end Class
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
ArrayIndexOutOfBoundExcept |
9 | 80 | |
java stored proc example | 9 | 29 | |
hibernate example for saving data | 19 | 37 | |
Facing this issue for maven proxy setting | 2 | 9 |
Join the community of 500,000 technology professionals and ask your questions.