answer.
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
bonufazy [111]
2 years ago
14

A class of Students was previously defined with the following properties: a string name, an integer age, a Boolean variable indi

cating whether or not the student is an IT major, and a character gender. 2 constructors were also defined: one default constructor and one constructor that takes the name, age, major, and gender to set the data fields. The instance methods were also defined, including the getters and setters. Two instances of the student class were also created; one with set values, and the other taking data from the user. For this activity, you will: Create an instance method called displayInfo(), that will use the getters and setters to print the instance data. Create a running class in which you’ll paste the 2 instances of student class created in the previous activity, then call the displayInfo() method to print then You want to track the number of students enrolled. Modify your Student class to include that variable and a method to get it. Your running class should: Display the current number of students enrolled; that is, print the number of students after each instance is created, along with new student information You are to create one more student, taking data from the user.
track the number of students enrolled. Modify your Student class to include that variable and a method to get it.
Computers and Technology
1 answer:
Alex Ar [27]2 years ago
3 0

Answer:

The Java program is explained below

Explanation:

###################################################

public class Student

{

  private String name;

  private int age;

  private Boolean IT_major;

  private char gender;

  public static int num; //static variable for number of students

  public Student() //default constructor

  {

      name = "Jon Doe";

      age = 0;

      IT_major = false;

      gender = '\u0000';

      num++;

  }

  public Student(String name,char gender) //parameterized constructor

  {

      this.name = name;

      this.gender = gender ;

      num++;

  }

  public void setAge(int Birth_year,int Current_year) //set age by sending birth year and current year

  {

      age = Current_year - Birth_year;

  }

  public int getAge()

  {

      return age;

  }

  public void setIT_Major(String major)

  {

      IT_major = Is_IT_major(major); //call Is_IT_major()

  }

  public boolean Is_IT_major(String major) //check if student is IT_major

  {

      if(major.equalsIgnoreCase("IT")|| major.equalsIgnoreCase("Information Technology"))

          return true;

      else

          return false;

  }

  public Boolean getIT_major()

  {

      return IT_major;

  }

 

  public String getName(){

      return name;

  }

 

  public char getGender(){

      return gender;

  }

  public String toString() //override toString()

  {

      return "\nStudent Details: \nName :"+name+" \nAge : "+ getAge()+ "\ngender : "+gender +"\nIs IT Major : "+getIT_major();

  }

 

  public void displayInfo(){

      System.out.println("Name: "+getName());

      System.out.println("Age: "+getAge());

      System.out.println("Gender: "+getGender());

      System.out.println("Is It Major: "+getIT_major());

  }

}

##############################################################

import java.time.LocalDate;

public class Test

{

  public static void main (String[] args)

  {

      LocalDate d = LocalDate.of(2017, 04, 07); // LocalDate object

      int Current_year = d.getYear();

      Student s = new Student("Christina Lewis",'f');

      s.setIT_Major("It");

      s.setAge(2000,Current_year);

      s.displayInfo();

      System.out.println("Number of students :"+s.num);

     

      System.out.println();

      Student s1 = new Student("Alex Bob",'m');

      s1.setIT_Major("It");

      s1.setAge(2000,Current_year);

      s1.displayInfo();

      System.out.println("Number of students :"+s.num);

  }

}

/*

Sample run:

Name: Christina Lewis

Age: 17

Gender: f

Is It Major: true

Number of students :1

Name: Alex Bob

Age: 17

Gender: m

Is It Major: true

Number of students :2

*/

You might be interested in
James has created some artwork portraying life on a different planet. He wants to show a world where everything is beautiful and
PIT_PIT [208]
What are the answer choices if so can you please post it with answer choices ?
5 0
2 years ago
Which mechanisms do we use to transport binary data and memory addresses?
Sav [38]

Answer:

The External Data Bus  is used to transport binary data and Address bus is used to transport memory addresses.

Explanation:

  • External Data Bus is a combination of data bus and external bus. Data bus is used to carry data and instructions between two or more components in the system e.g. CPU and all other computer components.
  • External bus is also called expansion bus. It is used to connect external components to the computer. Its a communication medium between CPU and other components. These components can be peripheral device like USB or flash memory.
  • So External Data Bus is used to transport data between CPU and external components. It is a primary communication pathway for data in a computer. The external data components are connected to this bus and the instruction or data on this bus is available to all external components. But the data communication is slower as compared to that of internal bus.
  • Address Bus carries physical location or address of data and transports memory addresses. Processor uses address bus when it wants to read data from memory or write data to the memory by sending a read/write signal by placing the read/write address of the specific memory location on the address bus.

 

6 0
2 years ago
Which of the following statements is true? Using existing exceptions makes the program less robust. Always create your own excep
hjlf

Answer:

The third option is correct.

Explanation:

The following option is true because it's a derived with that Throwable class. More than that exception type, it is also other category called Error originating through that Throwable class. As any other class, the exception class will also include fields as well as functions. So, the following are the reason that describes the following answer is true according to the exception class.

The other options are not appropriate according to the following scenario.

8 0
2 years ago
Consider the following method intended to modify the parameter names by removing all instances of the String n.
Anastasy [175]

Answer:

int i = 0; i < names.size(); i++

Explanation:

The ArrayList must be read in the forward direction, and it is going to start from 0 certainly. Also, the iteration is going to end when i is exactly one less than the size of the ArrayList. And this is possible only if we choose the option mentioned in the Answer section. In this, i starts from 0 and iterates till i is one less than name.size() which is the size of the ArrayList.

7 0
2 years ago
Which of the following is not a characteristic of a good value log entry
Stolb23 [73]
What are we supposed to find? Help us
6 0
1 year ago
Other questions:
  • Foods that are high in _________ have the least impact on slowing the body's absorption rate of alcohol.
    5·1 answer
  • Grabar microphone audio icon_person click each item to hear a list of vocabulary words from the lesson. then, record yourself sa
    7·2 answers
  • Isabel is creating a wireframe. She has drawn a layout for the home page along with outlining the navigation elements. She now w
    15·2 answers
  • ______ is a certification program that recognizes sustainable building practices and strategies. Question 1 options: A) Brundtla
    10·1 answer
  • Suppose a computer using direct mapped cache has 220 bytes of byte-addressable main memory, and a cache of 32 blocks, where each
    5·1 answer
  • Implement the function couple, which takes in two lists and returns a list that contains lists with i-th elements of two sequenc
    8·1 answer
  • What happened if the offshore team members are not able to participate in the iterations demo due to timezone/infrastructure iss
    12·1 answer
  • print_pattern() prints 5 characters. Call print_pattern() twice to print 10 characters. Example output: ***** ***** in python
    7·1 answer
  • Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lowe
    8·1 answer
  • A retailer is able to track which products draw the most attention from its customers through the use of 5g-enabled motion senso
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!