question archive Create class Student with the private attributes int studentId String studentName, studentAddress, collegeName

Create class Student with the private attributes int studentId String studentName, studentAddress, collegeName

Subject:Computer SciencePrice:4.87 Bought7

Create class Student with the private attributes int studentId String studentName, studentAddress, collegeName. 

Include appropriate getter methods.

Assume most of the students are from "NIT" college. So user has to give input whether the student is from NIT or not. 

  1. If student belongs to NIT, give input as 'yes/YES' and skip input for the attribute collegeName and create student object with 3-argument constructor to initilze the values for studentId, studentName and studentAddress and collegeName as "NIT".
  2. If student belongs to other college, give input as 'no/NO' and get college name from the user and create student object with 4-argument constructor to initialize all the values. 
  3. Instead of Yes / No, if user enters different input then display 'Wrong Input' and get the input again.

Based on the above assumptions write the necessary constructors in the Student class.

Write a class StudentMain with the main method and test the application.  

Sample Input 1:

Enter Student's Id:

12

Enter Student's Name:

John

Enter Student's address:

Chennai

Whether the student is from NIT(Yes/No):

NO

Enter the college name:

SVS

Sample Output 1:

Student id:12

Student name:John

Address:Chennai

College name:SVS

Sample Input 2:

Enter Student's Id:

43

Enter Student's Name:

Tom

Enter Student's address:

Coimbatore

Whether the student is from NIT(Yes/No):

y

Wrong Input

Whether the student is from NIT(Yes/No):

yes

Sample Output 2:

Student id:43

Student name:Tom

Address:Coimbatore

College name:NIT

 

Option 1

Low Cost Option
Download this past answer in few clicks

4.87 USD

PURCHASE SOLUTION

Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

rated 5 stars

Purchased 7 times

Completion Status 100%