Menu

[Solved]Java Create Java Class Nameperson Example Output Would User Inputs Sophia 206999109 2 Outp Q37050916

java

create java class “nameperson”
the example of output would be this:
//if the user inputs
sophia 206999109 2
//then the output shows this
My name is None and my studentid is 0
My name is sophia and studentid is 0
My name is sophia and studentid is 206999109
My grade is 2

so i have to create two classes  
class nameperson{
}

class studentid extends person{

}
class grade extends studentid{
}

my main method is this
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
       Person[] people = newPerson[3];
       int studentid, grade;
String name;

       name = sc.next();
       studentid = sc.nextInt();
       grade = sc.nextInt();
       people[0] = new Person();
       people[1] = new Person(name);
       people[2] = new Person(name,studentid);
       people[3] = new grade(grade);
       for (int i = 0; i <people.length; i++)
          people[i].writeOutput();
      
       sc.close();
}
}

Expert Answer


Answer to java create java class “nameperson” the example of output would be this: //if the user inputs sophia 206999109 2 //then … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *