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]
3 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]3 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
Your company requires computers to authenticate to one another and enforces this requirement with Windows Defender Firewall with
lubasha [3.4K]

There are a lot of rules in computing. The above can be done with authentication exemption.

<h3>What is Authentication exemptions?</h3>

This is a method that helps one to be able to specify a particular group of computers.

Conclusively, This can be done via their Active Directory computer account name or the use of their IP address. Tis does not apply to existing connection security rules.

Learn more about   authentication exemption from

brainly.com/question/25739714

7 0
2 years ago
Jamie is not sure a new medication will work because it has not had a large test group. Is Jamie being creative?
Mumz [18]
No, they're being skeptical.
4 0
3 years ago
Read 2 more answers
____ lets you store your data remotely and access it with any device connected to the internet.
Gre4nikov [31]
Either iCloud or air drop
6 0
3 years ago
Will creates an entry in his calendar and marks it as an all-day instance. Which item has he created?
Hatshy [7]

Answer:

The answer u looking for is event

5 0
3 years ago
Read 2 more answers
The Double.parseDouble() method requires a String argument, but it fails if the String cannot be converted to a floating-point n
Andrei [34K]

Answer:

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        String numStr = input.nextLine();
  6.        double num;
  7.        try{
  8.            num = Double.parseDouble(numStr);
  9.        }
  10.        catch(NumberFormatException e){
  11.            num = 0;
  12.            System.out.println("Value entered cannot be converted to a floating point number.");
  13.        }
  14.    }
  15. }

Explanation:

The solution code is written in Java.

Firstly, we create a Scanner object and prompt user to input a number (Line 5-6). Next, we create a try -catch block and place the parseDouble inside the try block. If the input is invalid (e.g. "abc"), a NumberFormatException error will be thrown and captured and set the num to 0 and display the error message (Line 11 - 13).  

3 0
3 years ago
Other questions:
  • A job posting is the best way to find out what _____ are required for a position.A.aptitudes B.hard skills C.soft skills D.dress
    10·2 answers
  • __________ is when a person feels compelled to acquire and abuse a drug despite the harm it causes him or her personally, and de
    7·2 answers
  • What option is used to combine several objects so that they can be treated as a single unit
    6·1 answer
  • Amy just added a 462 meter run of fiber optic cable to the network what should she do next?
    10·1 answer
  • Your boss is very skeptical about the idea of storing his files up in the cloud rather than on a local storage drive. He asks yo
    7·1 answer
  • A(n) _____ is a request for the database management software to search the database for data that match criteria specified by th
    15·2 answers
  • HELPPPP KOKICHI IS OUT TO KILL ME
    11·1 answer
  • Match the characteristics to the mobile operating system that it describes.
    6·1 answer
  • I need the full code for 6.1.3 code hs circles and squares please answer please help
    12·1 answer
  • The federal communications commission oversees the programming of which entities?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!