Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class using the following specifications and data type, access modifiers

ID: 3666533 • Letter: W

Question

Write a class using the following specifications and data type, access modifiers and return types as appropriate.

Nmae the class Person

instance variables are name of a data type Sring and age of a data type int.

default constructor using the default ""for String and 0 for int.

formal overloaded contructor accepting the formal parameters newName and newAge . and initializing the instance variables.

Method named printPerson which only prints the following 2 lines using xxx for the instance variable value.

This person's name is : xxx

This person's age is :xxx

Explanation / Answer

Class Person{

       String name ;

       int age;

      Person(){

            name ="";

            age = 0;

     Person(String newName , int newAge ){

              name = newName;

              age = newAge;

      }

     void printPerson(){

                 cout <<"This person's name is : "<<name ;

                    cout<<"This person's age is :"<<age;

     }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote