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
Luba_88 [7]
3 years ago
14

A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static Ar

rayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList.

Computers and Technology
1 answer:
aleksandr82 [10.1K]3 years ago
4 0

Answer:

Check the explanation

Explanation:

CODE:-

import java.util.ArrayList;

class Student

{

  private String name;

  private int grade;

  private static ArrayList<Student> classList = new ArrayList<Student>();

 

  public Student(String name, int grade)

  {

      this.name = name;

      this.grade = grade;

      classList.add(this);

  }

 

  public String getName()

  {

      return this.name;

  }

 

  /*Don't change the code in this method!

  This method will print out all the Student names in the classList Array

  */

  public static String printClassList()

  {

      String names = "";

      for(Student name: classList)

      {

          names+= name.getName() + "\n";

      }

      return "Student Class List:\n" + names;

  }

}

public class ClassListTester

{

  public static void main(String[] args)

  {

      //You don't need to change anything here, but feel free to add more Students!

      Student alan = new Student("Alan", 11);

      Student kevin = new Student("Kevin", 10);

      Student annie = new Student("Annie", 12);

      Student smith = new Student("Smith", 11);

      Student kane = new Student("Kane", 10);

      Student virat = new Student("Virat", 12);

      Student abd = new Student("ABD", 12);

      Student root = new Student("Root", 12);

      System.out.println(Student.printClassList());

  }

}

Kindly check the attached image below.

You might be interested in
_____ rows indicate that there is different formatting for odd and even rows.
Sladkaya [172]
Banded rows indicate that there are different formatting for odd and even rows.
5 0
3 years ago
Write a public member function which replace that replaces one occurrence of a given item in the ArrayBag with another passed as
ira [324]

Answer:

The method is written in Java

public static boolean abc(int [] ArrayBag,int num, int replace){

    Boolean done = false;

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

        if(ArrayBag[i] == num){

            ArrayBag[i] = replace;

            done = true;

        }

    }

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

        System.out.println(ArrayBag[i]+" ");

    }

    return done;

}

Explanation:

The method is written in java

The arguments of the method are:

<em>1. ArrayBag -> The array declares as integer</em>

<em>2. num -> The array element to check the presence</em>

<em>3. replace - > The replacement variable</em>

This line defines the method as boolean.

public static boolean abc(int [] ArrayBag,int num, int replace){

This line declares a boolean variable as false

    Boolean done = false;

The following iterates through the elements of the array

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

This checks if the array element exist

        if(ArrayBag[i] == num){

If yes, the array element is replaced

            ArrayBag[i] = replace;

The boolean variable is updated from false to true

            done = true;

        }

    }

The following iteration prints the elements of the array

<em>     for(int i = 0;i<ArrayBag.length;i++){</em>

<em>         System.out.println(ArrayBag[i]+" ");</em>

<em>     }</em>

This prints returns the boolean thats indicates if replacement was done or not.

    return done;

}

<em>Attached to this solution is the program source file that includes the main method of the program</em>

Download txt
5 0
3 years ago
Draw a flowchart that solve the problem of calculating the average of 5 numbers.
KatRina [158]

Answer:

Draw a flowchart that solve the problem of calculating the Area of circle

Pie x r x2

Explanation:

3 0
2 years ago
You are studying for a test tomorrow. Your friends invite you to
lapo4ka [179]

Answer: C

Explanation:

7 0
3 years ago
You can include up to _____ logical conditions in the and function.
Margaret [11]
You can include up to 255 logical conditions in the AND function. This is to test multiple<span> conditions at the same time.
</span><span>The syntax of the AND function is the following: =AND (logical1, [logical2], ...)</span><span>
The AND function can be true (one) and false (null), only one of these two values.
</span><span>The AND function will return #VALUE if no logical values are found or created during evaluation.</span>
5 0
3 years ago
Other questions:
  • If you quote an author from a website in a paper, it will be important to create a _____ in your writing to give them credit for
    7·2 answers
  • Which type of software-generated problems can indicate that a software bug is causing a memory error?
    11·1 answer
  • An indirect effect of an action, be it a cost or benefit, for a third party who did not agree to the action is known as a(n) ___
    8·1 answer
  • Which is a credit card balance A. The amount of interest you must pay the credit card company B. The required minimum payment to
    5·1 answer
  • Often used in connection with a business
    6·1 answer
  • A user clicked an email link that led to a website than infected the workstation with a virus. The virus encrypted all the netwo
    10·1 answer
  • Create a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop shou
    5·1 answer
  • ________ allows the computer to get its configuration information from the network instead of the network administrator providin
    5·1 answer
  • fun fact about London(me): when it comes to relationships she becomes clingy to the person shes dating
    10·1 answer
  • Which sentence describe internet safety precautions?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!