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
nordsb [41]
4 years ago
7

Write a class called (d) Teacher that has just a main method. The main method should construct a GradeBook for a class with two

students, "Jack" and "Jill". Jack’s grades on the three tests for the class are 33, 55, and 77. Jill’s grades are 99, 66, and 33. After constructing the GradeBook object, main should use the instance methods of the GradeBook class to determine the name of the student with the highest average grades. Print the name of this student on the screen.
Computers and Technology
1 answer:
podryga [215]4 years ago
8 0

Answer:

The java program is given below.

import java.util.*;

class GradeBook  

{

//variables to hold all the given values

static int m11, m12, m13;

static int m21, m22, m23;

static String name1, name2;

//variables to hold the computed values

static double avg1, avg2;

//constructor initializing the variables with the given values

GradeBook()

{

name1 = "Jack";

m11 = 33;

m12 = 55;

m13 = 77;

name2 = "Jill";

m21 = 99;

m22 = 66;

m23 = 33;

}

//method to compute and display the student having highest average grade

static void computeAvg()

{

avg1=(m11+m12+m13)/3;

avg2=(m21+m22+m23)/3;

if(avg1>avg2)

System.out.println("Student with highest average is "+ name1);

else

System.out.println("Student with highest average is "+ name2);

}  

}

//contains only main() method

public class Teacher{  

public static void main(String[] args)

{

//object created

GradeBook ob = new GradeBook();

//object used to call the method

ob.computeAvg();

}

}

OUTPUT

Student with highest average is Jill

Explanation:

1. The class GradeBook declares all the required variables as static with appropriate data types, integer for grades and double for average grade.

2. Inside the constructor, the given values are assigned to the variables.

3. The method, computeAvg(), computes the average grade of both the students. The student having highest average grade is displayed using System.out.println() method.

4. Inside the class, Teacher, the main() method only has 2 lines of code.

5. The object of the class GradeBook is created.

6. The object is used to call the method, computeAvg(), which displays the message on the screen.

7. All the methods are also declared static except the constructor. The constructor cannot have any return type nor any access specifier.

8. The program does not takes any user input.

9. The program can be executed with different values of grades and names of the students.

You might be interested in
Why is it a mistake to put e-mail address of people who don't know each other in the "to:" field
Ber [7]
They would probably think that you sent the email to the wrong person and then delete it.
7 0
4 years ago
Read 2 more answers
What is the defining difference between computer security and information security?
Alekssandra [29.7K]
Computer security is protection from theft or damage to their hardware, software, or information, as well as disruption or misdriection of the services they provide. As information security is the practice of preventing unauthorized access, use, disclosure, disruption, modification, inspection, recording, or destruction of information.
4 0
3 years ago
What are some cloud storage devices?​
ryzh [129]

i believe some are google docs, apple icloud, xdrive, MediaMax, and Strongspace

6 0
3 years ago
Audio tools support reading fluency by
Artist 52 [7]

Answer:

The answer is "demonstrating how a text is read".

Explanation:

Audio tools like Text to Speech are commonplace in programs like Duolingo. They offer you a somewhat accurate example of how to properly pronounce a word or phrase.

4 0
4 years ago
Read 2 more answers
Write the definition of a function, is_reverse, whose two parameters are arrays of integers of equal size. The function returns
Alisiya [41]

Answer:

def is_reverse(lst1, lst2):

   lst2 = lst2[::-1]

   if lst1 == lst2:

       return True

   else:

       return False

Explanation:

Create a function called is_reverse that takes two parameters, lst1 and lst2

Reverse the second list using slicing

Check if the first list and the second list are equal to each other. If they are, return True. Otherwise, return False

4 0
3 years ago
Other questions:
  • How have computers changed overtime
    13·2 answers
  • What is the meaning of Android
    12·2 answers
  • Oop skskskssksksksksk
    15·2 answers
  • Which one is correct?
    7·2 answers
  • Ethernet is a standard for a) LAN b) MAN c) WAN d) All of the above
    14·2 answers
  • Why am I not getting the activation link for my account?
    11·1 answer
  • What is presentation software in bussiness used for
    9·1 answer
  • Write a program that will draw a red circle on top of a blue square in the center of the canvas. The blue square should have sid
    12·1 answer
  • A company is looking for an employee to help organize customer information for the sales team. Which computer field includes thi
    15·2 answers
  • What does this comparison block indicate?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!