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
Which one of the following is the best example of an authorization control? (a)- Biometric device (b)- Digital certificate (c)-A
DedPeter [7]

Answer:

A

Explanation:

Biometric device is the best example of authorization / identify control.

7 0
2 years ago
Write the prototype for a function named showValues. It should accept an array of integers and an integer for the array size as
aalyn [17]

Answer:

void showValues(int [<em>maximum</em><em> </em><em>volume</em>],int);

4 0
2 years ago
Read 3 more answers
The _______________ domain refers to any endpoint device used by end users, which includes but is not limited to mean any smart
viva [34]
The answer is <span>workstation.   </span>The workstation domain refers to any endpoint device used by end users, which includes but is not limited to mean any smart device in the end user's physical possession and any device accessed by the end user, such as a smartphone, laptop, workstation, or mobile device.
5 0
2 years ago
Which telecommunications device is widely used in industries that require closed communication?
Stella [2.4K]

The telecommunications device that  is widely used in industries that require closed communication are walkie-talkies. Correct answer: D

Walkie-talkies are hand-held, portable, two-way radio transceivers which enable secure communication between the two points, without being part of a network.

3 0
2 years ago
Read 2 more answers
You resurrected an old worksheet. It appears to contain most of the information that you need, but not all of it. Which step sho
vagabundo [1.1K]

Answer:

The answer is "check the worksheet is not read only"

Explanation:

The read only mode is used for read the file data, and it doesn't allows the user to update the file, and for updating the worksheet we should check iut does not open in the read-only mode.

If it is open, then we close it and for close we goto the office button and click on the tools option after that goto general setting, in this there is a check box for turn off the read-only mode.

 

8 0
2 years ago
Other questions:
  • Name an analog quantity other than temperature and sound.
    14·1 answer
  • The bit width of the LRU counter for a 32 KB 16-way set associative cache with 32 Byte line size is
    13·1 answer
  • Why can't you use Friedman's attack on block ciphers?
    12·1 answer
  • The ______ network became functional in 1969, linking scientific and academic researchers across the United States. Group of ans
    7·2 answers
  • Write a program that reads the lengths of the sides of a triangle from the user. Compute the area of the triangle using Heron's
    8·1 answer
  • A program is divided into 3 blocks that are being compiled on 3 parallel computers. Each block takes an Exponential amount of ti
    6·1 answer
  • Which of the following is true of how computers represent numbers?
    9·2 answers
  • You modify a document that is saved on your computer. Where are the changes stored until you save the document again?
    12·1 answer
  • there is a structure called employee that holds information like employee code, name, date of joining. Write a program to create
    13·1 answer
  • Ali has created a small program in Python, but he wants to store his data in a multi-dimensional array. He would like to use adv
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!