Question

In: Computer Science

Using C++ Design a class named PersonData with the following member variables: lastName firstName address city...

Using C++ Design a class named PersonData with the following member variables:

  1. lastName
  2. firstName
  3. address
  4. city
  5. state
  6. zip
  7. phone

and at a minimum the following member functions:

  1. A class constructor - which initializes all the member variables above
  2. a display() function - which ONLY displays all the person's data to the console
  3. Also write the appropriate accessor/mutator functions for the member variables

Write a NewPersonData function. This is a stand-alone function that you can use in your main to generates a new PersonData object from user input (i.e. internally prompting and retrieving the values necessary to generate a person)

  • prototype - PersonData NewPersonData();
  • how to call - PersonData person = NewPersonData();

Solutions

Expert Solution

Answer: hi!! dear student kindly find your solution below. Let me know if any issue. Thanks.

C++ Code:

#include<iostream>
using namespace std;
void NewPersonData()
{
string fna,lna,cty,st;
int zi,pho;
cout<<endl<<"Enter firstNAme:";
cin>>fna;
cout<<endl<<"Enter firstNAme:";
cin>>lna;
cout<<endl<<"Enter city:";
cin>>cty;
cout<<endl<<"Enter State:";
cin>>st;
cout<<endl<<"Enter Zip code:";
cin>>zi;
cout<<endl<<"Enter Phone number:";
cin>>pho;
cout<<endl<<"New PersonData";
cout<<"\n lastName-"<<lna;
   cout<<"\n firstName-"<<fna;
   cout<<"\n city-"<<cty;
   cout<<"\n state-"<<st;
   cout<<"\n Zip-"<<zi;
   cout<<"\n Phone-"<<pho;
}
class PersonData
{
public:
   string lastName,firstName;
   string city,state;
   int zip,phone;
   PersonData()
   {
   lastName = " ";
   firstName = " ";
   city = " ";
   zip =0;
   phone = 0;
   state = "";
   }
   void set_data(string lna,string fna,string ct,string st,int z,int p)
   {
   lastName = lna;
   firstName = fna;
   city = ct;
   zip =z;
   phone = p;
   state = st;
   }
   string get_fna()
   {
   return firstName;
   }
   string get_lna()
   {
   return lastName;
   }
   string get_city()
   {
   return city;
   }
   string get_state()
   {
   return state;
   }
   int get_zip()
   {
   return zip;
   }
   int get_phone()
   {
   return phone;
   }
   void display()
   {
   cout<<"\n lastName: "<<lastName;
   cout<<"\n firstName: "<<firstName;
   cout<<"\n city: "<<city;
   cout<<"\n state: "<<state;
   cout<<"\n Zip: "<<zip;
   cout<<"\n Phone: "<<phone;
   }
};
int main()
{
  
PersonData person;
person.set_data("Li","Robin","Newzeland","Rubreka",45324,999777444);
person.display();
NewPersonData();
return 0;
}

Output:


Related Solutions

C++ PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName...
C++ PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData, which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool. It will...
write the code in python Design a class named PersonData with the following member variables: lastName...
write the code in python Design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData , which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool ....
C++ Classes & Objects Create a class named Student that has three private member: string firstName...
C++ Classes & Objects Create a class named Student that has three private member: string firstName string lastName int studentID Write the required mutator and accessor methods/functions (get/set methods) to display or modify the objects. In the 'main' function do the following (1) Create a student object "student1". (2) Use set methods to assign StudentID: 6337130 firstName: Sandy lastName: Santos (3) Display the students detail using get functions in standard output using cout: Sandy Santos 6337130
Database Normalize the relations to BCNF: Member- (MemID, dateJoined, firstName, lastName, street, city, state, zip, areaCode,...
Database Normalize the relations to BCNF: Member- (MemID, dateJoined, firstName, lastName, street, city, state, zip, areaCode, phoneNumber, currentOfficeHeld) Play- (title, author, numberOfActs, setChanges) Sponsor- (sponID, name, street, city, state, zip, areaCode, phoneNumber) Subscriber- (subID, firstName, lastName, street, city, state, zip, areaCode, phoneNumber) Production- (prodyear, seasonStartDate, seasonEndDate, title) Performance – (perfyear,perfdate, time, seasonStartDate) TicketSale- (saleID, saleDate, totalAmount, perfyear, perfdate,subID) DuesPayment- (MemID, duesYear, amount, datePaid) Donation – (sponID, donationDate, donationType, donationValue, prodYear, seasonStartDate) Ticket- (saleID, seatLocation, price, type) Member - Production-(MemID, prodYear,...
Car Class Write a class named Car that has the following member variables: • year. An...
Car Class Write a class named Car that has the following member variables: • year. An int that holds the car’s model year. • make. A string object that holds the make of the car. • speed. An int that holds the car’s current speed. In addition, the class should have the following member functions. • Constructor. The constructor should accept the car’s year and make as arguments and assign these values to the object’s year and make member variables....
SQL ONLY- Given Tables- Employee (EmployeeID, FirstName, LastName, Address) Department (DeptNo, DepartmentName, City) DepartmentEmployee(DeptNo, EmployeeID, Position)...
SQL ONLY- Given Tables- Employee (EmployeeID, FirstName, LastName, Address) Department (DeptNo, DepartmentName, City) DepartmentEmployee(DeptNo, EmployeeID, Position) Project (ProjectNo, ProjectName, DeptNo) Project Team ( ProjectNo, EmployeeID, Role) MAKE THE QUERY FOR- 1. List the name and position of all the employee who works in the (DeptNo = ‘22C’). 2. List the total number of employees in each department for those departments with more than 5 employees. 3. List the project number, project name and the number of employees who worked on...
/*Design and code a class Calculator that has the following * tow integer member variables, num1...
/*Design and code a class Calculator that has the following * tow integer member variables, num1 and num2. * - a method to display the sum of the two integers * - a method to display the product * - a method to display the difference * - a method to display the quotient * - a method to display the modulo (num1%num2) * - a method toString() to return num1 and num2 in a string * - Test your...
In C++ please Your class could have the following member functions and member variables. However, it's...
In C++ please Your class could have the following member functions and member variables. However, it's up to you to design the class however you like. The following is a suggestion, you can add more member variables and functions or remove any as you like, except shuffle() and printDeck(): (Note: operators must be implemented) bool empty(); //returns true if deck has no cards int cardIndex; //marks the index of the next card in the deck Card deck[52];// this is your...
***IN JAVA*** Write a program contained a class Student which has firstName, lastName, mark, grade. The...
***IN JAVA*** Write a program contained a class Student which has firstName, lastName, mark, grade. The program should allow creation an array of object instances to assign firstName, lastName and mark from input user and perform and assign grade based on mark’s criteria displayed below. MARKS INTERVAL 95 - 100 90 - <95 85 - <90 80 - <85 75 - <80 70 - <75 65 - <70 60 - <65 0 - <60 LETTER GRADE A+ A B+ B...
The Instructor class consists of a firstname (String), lastname (String), office building (String) and room number...
The Instructor class consists of a firstname (String), lastname (String), office building (String) and room number (int). There is a no-arg constructor that initializes the properties to “Albert”, “Einstein”, “McNair”, 420. There is also a constructor with a parameter for each class property. Finally, there is a toString() method that returns each property separated by an asterisk * . Create a Netbeans project and name it CourseScheduler. Implement the Instructor class in Java. Declare and instantiate two Instructor objects in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT