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
You live "out in the middle of nowhere" and feel there is no need to protect your internet connection because there is no one th
Anvisha [2.4K]

Potential uploaded viruses, personal information being lost, blackmail, identity theft.

7 0
2 years ago
Write a function called sum_scores. It should take four arguments, where each argument is the team's score for that quarter. It
saw5 [17]

Answer:

Here is the Python program which has a function sum_scores:

def sum_scores(score1, score2, score3, score4):

   sum = score1 + score2 + score3 + score4

   print(sum)    

sum_scores(14,7,3,0)

Explanation:

  • Method sum_scores takes four arguments, score1, score2, score3, score4.
  • The sum variable adds these four scores and stores the value of their addition.
  • Lastly print statement is used to print the value stored in sum variable which is the value obtained by adding the four scores.
  • Last statement calls the sum_scores method and passes four values to it which are 14,7,3,0
  • The output of the above program is:
  • 24
  • If you want to use return statement instead of print statement you can replace print(sum) with return sum. But in order to display the sum of the scores you can replace sum_scores(14,7,3,0) with print(sum_scores(14,7,3,0))
  • The program along with the output is attached as a screenshot.

5 0
2 years ago
Which is true for a hosted blog software
professor190 [17]
Since you have not provided the choices wherein I will have to choose from to arrive at an answer, I will just explain to you the concept revolving around a hosted blog software. Hosted blog software are basically installed by the owner of the web server in which among its famous platforms is the Blogger.
7 0
2 years ago
Read 2 more answers
Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255
maxonik [38]

Answer:

Follows are the code to this question:

#include <iostream>//defining a header file

using namespace std; //using namespace

int main() //defining main method

{

int red,green,blue,s; //defining integer variable

cout<<"Enter value: \n ";//print message

cin>>red>>green>>blue; //input value

if(red<green && red<blue)//defining if block that checks red value

s=red;//store red variable value to s variable

else if(green<blue)//defining else if block that checks green value less then blue

s=green;//store green variable value in s variable

else//defining else block

s=blue; //store blue variable value in s variable

//calculating red, green, blue value

red=red-s;//store red value

green=green-s;//store green value

blue=blue-s;//store blue value

cout<<red<<" "<<green<<" "<<blue;

}

Output:

Enter value:

130  

50

130

80 0 80

Explanation:

In the above code, inside the Main method, four integer variable "red, green, blue, and s" is defined, in which "red, green, and blue" is used for input the value from the user end.

  • In the next step, a conditional statement is used, that checks the red variable value, if the condition is true, it will store its value in the "s" variable, otherwise, it will go to else if block.
  • In this block, the green variable checks its value less than then blue variable value, if the condition is true, it will store the green value in the "s" variable, otherwise, it will goto else block.
  • In this block, it will store the blue variable value in the "s" variable, and subtract the value of "red, green, and blue" value from "s" and store its value, and at the last, it will print its value.    
4 0
2 years ago
When performing actions between your computer and one that is infected with a virus, which of the following offers No risk of yo
daser333 [38]

Answer:

d

Explanation:

7 0
2 years ago
Other questions:
  • ___________ device that uses a light source to read characters, marks, and codes and then converts them into digital data that a
    11·1 answer
  • rite a method so that the main() code below can be replaced by simpler code that calls method calcMilesTraveled(). Original main
    7·1 answer
  • You are the IT security administrator for a small corporate network. Samuel Garcia (sgarcia) has been away on vacation and has f
    9·1 answer
  • 1. PGP encryption can be performed from the command line as well. What is the PGP command line syntax to encrypt the my-message.
    7·1 answer
  • The vast amount of data collected from Internet searches, social media posts, customer transactions, military
    8·1 answer
  • In this assignment, you are provided with working code that does the following: 1. You input a sentence (containing no more than
    14·1 answer
  • Write a program that plays a reverse guessing game with the user. The user thinks of a number between 1 and 10, and the computer
    5·1 answer
  • Programmers often author which type of information to guide test runs?
    10·1 answer
  • Which change signaled a musical progression toward rock and roll?
    14·1 answer
  • Plz help code practice for python
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!