Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.
// 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
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
// 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
Join the community of 500,000 technology professionals and ask your questions.