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
Masteriza [31]
3 years ago
5

Now that the classList Array has been implemented, we need to create methods to access the list items.

Computers and Technology
1 answer:
natima [27]3 years ago
7 0

The following code will be applied to Create the following static methods for the Student class

<u>Explanation:</u>

/* Note: Array index starts from 0 in java so ,, user ask for 1 index then the position will be i-1 , below program is based on this concept if you dont want this way just remove -1 from classList.get(i-1).getName(); ,and classList.add(i-1,student); */

/* ClassListTester.java */

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);

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

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

System.out.println(Student.getStudent(1));

Student.addStudent(2, new Student("Trevor", 12));

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

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

}

}

/* Student.java */

import java.util.ArrayList;

public class Student

{

private String name;

private int grade;

//Implement classList here:

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;

}

//Add the static methods here:

public static String printClassList()

{

String names = "";

for(Student name: classList)

{

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

}

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

}  

public static String getLastStudent() {

// index run from 0 so last student will be size -1

return classList.get(classList.size()-1).getName();

}

public static String getStudent(int i) {

// array starts from 0 so i-1 will be the student

return classList.get(i-1).getName();

}

public static void addStudent(int i, Student student) {

// array starts from 0 so, we add at i-1 position

classList.add(i-1,student);

// remove extra student

classList.remove(classList.size()-1);

}  

public static int getClassSize() {

return classList.size();

}

}

You might be interested in
The WAN connections to your regional offices are unfortunately extremely slow for your users and they are complaining about file
Zanzabum

Answer: (B) Branch cache

Explanation:

  The branch cache is the process of cache the data from the given file and the wen server on the wide area network. In the WAN connection, the branch code is the type of functionality which basically allow the window to providing the remote user support in the network. The branch cache basically work on the two mode that are:

  • The distributed mode
  • The host mode

The branch cache is the one of the technology that intend the cache data for reducing the network traffic in the wide are network.

Therefore, Option (B) is correct.

5 0
3 years ago
You decide to buy some stocks for a certain price and then sell them at anotherprice. Write a program that determines whether or
Otrada [13]

Answer:

no_of_shares = int(input("Enter the number of shares: "))

purchase_price = float(input("Enter the purchase price of the stock: "))

sale_price = float(input("Enter the sale price of the stock: "))

total_stock_price = purchase_price*no_of_shares

total_spend_on_buying = total_stock_price + (0.03*total_stock_price)

total_sale_price = sale_price*no_of_shares

commission_while_selling = total_sale_price*0.03

net_gain_or_loss = total_sale_price - (total_spend_on_buying + commission_while_selling)

if(net_gain_or_loss<0):

print("After the transaction, you lost {} dollars".format(abs(net_gain_or_loss)))

else:

print("After the transaction, you made {} dollars".format(abs(net_gain_or_loss)))

7 0
3 years ago
Help me please I dont have enough points for people just to get these for free
Gekata [30.6K]

Answer:

help me please I dont have enough points for people just to get these for free

Sam is a movie director. He has asked his storyboard artist to create an image of the central character looking ecstatic after receiving an award. What type of shot does the director need from the storyboard artist?

A. long shot

B. point of view shot

C. reaction shot

D. jump cut​

A is the asnwer

3 0
2 years ago
Which of the following is the best reason for including a photograph in a formal business document
Bond [772]

Answer:

The answer is "The reader wants to see how your product looks".

Explanation:

Some information is missing in the question. so, the correct choice can be described as follows:

  • The corporation uses records and reports to transfer facts, statistics, and figures, including explanations for enhancing activities, administration, and sales.  
  • It generally refers to the various documentation, all with various sections and contents.  
  • In the organization's usage of records for correspondence, transaction, and product research, that's why the "reader wants to see how your product looks" is the correct choice.
8 0
3 years ago
Please help,
MAXImum [283]

Answer:Answer I think it might be true Explanation in the Explanation

Explanation: So I think it might be true because Ergonomics is the science of conforming the workplace and all of its elements to the worker, and in the question it says that "How a product relates to the human body", so I think it might be true, Sorry if I got this wrong.

GOOOOOOD LUUUUUCCCCCCKK

8 0
3 years ago
Other questions:
  • Which finger types the highlighted keys on a number keypad? A. Third B. First C. Pinky D. Thumb
    7·2 answers
  • The first documented use of work release was in the ____.
    13·1 answer
  • What makes a distributed denial of service attack "distributed"? It involves many ip addresses. It attacks multiple systems. It
    9·1 answer
  • Create a function (prob3_6) that will do the following: Input a positive scalar integer x. If x is odd, multiply it by 3 and add
    15·1 answer
  • In a linked chain implementation of a queue, the performance of the enqueue operation
    10·1 answer
  • What is the reasoning you would write an inquiry to a company?
    5·2 answers
  • Why is failure important when you are designing a solution to a problem?
    6·2 answers
  • What number will be output by the console.log command on line 5?
    9·1 answer
  • Putting commands in correct order so computers can read the commands
    9·1 answer
  • What is the purpose of memory address?​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!