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
bonufazy [111]
4 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]4 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
When you open as many links as you want, and still stay in the same browser window instead of cluttering your screen with multip
emmainna [20.7K]

Answer:

a. Tabbed browsing

Explanation:

Tabbed browsing is a feature in the browser that helps in operating several tabs at the same time. It helps in browsing different links without opening different browsers. Multiple pages can be opened and surfed at the same time in one window. Any link can be opened in a different or new tab by clicking right on the link. After this, 'open link in new tab' is to be selected and the link gets opened respectively.

3 0
3 years ago
which of these tools stick to the edge of an image, thus making it easy to select the shape of an image
USPshnik [31]

Answer:

ljb lih lug outbpiyougvotvoy

outiyfiyfiyfiyffiyvitfurcutfcutcrcutfutcdu

Explanation:

didn't understand the question

3 0
3 years ago
The Internet Engineering Task Force (IETF) defines the protocols and standards for how the Internet works. The members of the IE
marta [7]

i believe the answer is b.

8 0
4 years ago
Which descriptions offer examples of Correction Services workers? Select all that apply.
lutik1710 [3]

B.) Doug supervises Jailers and makes sure their work meets standards.

E.) Rudy monitors people who are on probation and parole.

F.) Nancy guards inmates in a prison.

4 0
3 years ago
Given the following Area class, how would I call the calcAreaSquare method in AreaTest.java with square with side length of 6? p
Olin [163]

Answer:

You can call the static method using the following statement:

double area = Area.calcAreaSquare(3.5);

Explanation:

In  Java, a static method can be called by directly using the Area class name and followed with a dot syntax as shown above. This will invoke the calcAreaSquare() method and act on the input 3.5 and return the output to the variable area.  

Calling a static method doesn't need to go through a class instance.  

3 0
4 years ago
Other questions:
  • State College charges its departments for computer time usage on the campus mainframe. A student had access to the university co
    10·1 answer
  • What is an incremental backup?
    7·1 answer
  • Which device should be used for enabling a host to communicate with another host on a different network?
    9·1 answer
  • Given a link with a maximum transmission rate of 18 Mbps. Only two computers, X and Y, wish to transmit starting at time t = 0 s
    14·1 answer
  • Write a program that converts degrees Fahrenheit to Celsius using the following formula. degreesC = 5(degreesF – 32)/9 Prompt th
    6·1 answer
  • A printer is connected locally on Computer1 and is shared on the network. Computer2 installs the shared printer and connects to
    10·1 answer
  • Which allows for saving a setting on one device and having the setting synchronize to other devices? Choose two answers.
    12·1 answer
  • Conceptual note-taking is the act of writing down information in the order it is given. drawing attention to details with a mark
    8·2 answers
  • Write javascript code for the form that appears in the image below. you are expected to add validation to the name field, email
    10·2 answers
  • Shreya has combined all the cells in a single leftmost column in a table. Instead of identifying the category multiple times, sh
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!