1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Dima020 [189]
3 years ago
8

Grade Average Lab Assignment Purpose: The goal of this lab assignment is to learn how to use for loops and if/else commands. Wri

te a program that will calculate a numeric average and a letter grade for a student. The main method creates an object of the Grades class that sends two parameters to the Grade class constructor: a student name and the grades to be averaged.
Computers and Technology
1 answer:
miss Akunina [59]3 years ago
3 0
<h2>Answer:</h2><h2></h2>

//class to test the Grade class

public class GradeTest{

    public static void main(String []args){        

       //create the grades to be averaged

      double [] grades = {23, 45, 67, 12.6};

       

       //create an object of the Grade class and

       //pass in the necessary arguments to the constructor

       Grade grade = new Grade("John", grades);

       

       //print out the results from the Grade object.

       System.out.println("Your name is " + grade.getName());

       System.out.println("Your average score is " + grade.getAverage());

       System.out.println("Your letter grade is " + grade.getLetterGrade());

       

   }

}  //End of the GradeTest class

//The Grade class

class Grade {

   

   //create instance variables

   private String name;

   private double [] grades;

   

   //constructor for the class

  public Grade(String name, double [] grades){

       

       //initialize the instance variables

      this.name = name;

       this.grades = grades;

       

   }

   

   //method to return the name of the student

  public String getName(){

       //return the name

       return this.name;

   }

   

   

   //method to calculate the average of the grades

  public double getAverage(){

       

       double [] grades = this.grades;

       

       //initialize some needed variables

       double sum = 0;

       double average = 0;

       

       //loop through the grades array and add each element to the sum variable

       for(int i =0; i < grades.length; i++){

           sum += grades[0];    

       }

       

       //calculate the average

      average = sum / grades.length;

       

       //return the average grade

       return average;

     

   }

   

   

   //method the calculate the letter grade from the average

   public char getLetterGrade(){

       

       //initialize some variables

      double average = this.getAverage();

       char letterGrade;

       

       //check the average and determine its corresponding letter grade

       if(average >= 40 && average < 45){

           letterGrade = 'E';

       }

       else if(average >= 45 && average < 50){

           letterGrade = 'D';

       }

       else if(average >= 50 && average < 60){

           letterGrade = 'C';

       }

       else if(average >= 60 && average < 70){

           letterGrade = 'B';

       }

       else if(average >= 70 && average <= 100){

           letterGrade = 'A';

       }

       else {

           letterGrade = 'F';

       }

       //return the letter grade

       return letterGrade;

       

   }

   

}   //End of the Grade class

<h2>Sample Output:</h2>

Your name is John

Your average score is 23.0

Your letter grade is F

<h2>Explanation:</h2>

The code above is written in Java and it contains comments explaining important parts of the code. It also contains a sample output got from running the program. To run this on your machine, copy the code and save in a file named GradeTest.java

You might be interested in
Order the following routine maintenance tasks from most to least important when securing a computer. a. Verify anti-malware sett
spin [16.1K]

Answer:

The following are the order of the routine maintenance tasks that is C, A, B, D

Explanation:

For securing the computer system the user has to follow some steps related to the routine maintenance tasks.

  • Firstly, the user has to validate the settings on the Windows Update.
  • Then, they have to validate the settings on the anti-malware software.
  • Then, the user has to validate the setting related to the file-sharing system.
  • Finally, they have to validate the frequent optimization of hard drives or hard disks.
7 0
3 years ago
What needs to be done before depositing a check using a mobile app?
galben [10]

Answer:

The check needs to be signed in the back by you or whoever is depositing it.

7 0
2 years ago
Read 2 more answers
This type of software works with end users, application software, and computer hardware to handle the majority of technical deta
Lena [83]
System software will be the answer
3 0
4 years ago
Which of the following is the smallest aperture (f-stop) opening?
Firlakuza [10]

Answer:

E) f/16

Explanation:

6 0
4 years ago
The process by which information gets into memory storage is called
slavikrds [6]

Answer:

Encoding

Explanation:

Encoding is the first out of the four steps of turning information into long-term memory in our brain. Encoding involves attending to information, taking it in, and then processing it before we get it into memory. This information is then stored within the brain for later retrieval. When we listen, we pay attention. This attention drives the process of encoding. We can encode information based on various things like, meaning, sound, and visuals.

7 0
4 years ago
Other questions:
  • Which of these is NOT an advantage of the impact of computer careers.
    9·1 answer
  • Which signal types are represented by a continuous wave form?
    11·1 answer
  • does someone know of a website where I can find free essays or assignments already answered (right or wrong, ain't matter), kind
    15·1 answer
  • The ash and dust from a volcanic eruption can cause a _______ change in the environment.
    13·1 answer
  • In 1–2 sentences describe the purpose of comparison operators and give an example.
    10·1 answer
  • Should i change my profile pic<br> dont delete
    15·2 answers
  • What is performance? Multiple Choice measures how quickly a system performs a process or transaction a system that is not operat
    9·2 answers
  • Double click on a sheet tab to ______ the sheer
    9·2 answers
  • Words or symbols that help you narrow down your search are called:
    12·1 answer
  • What is the mest gun in pixel gun 3d imma give you brainliest
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!