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 ....
2. Consider the following relations: Doctor(SSN, FirstName, LastName, Specialty,YearsOfExperience, PhoneNum) Patient(SSN, FirstName, LastName, Address, DOB, PrimaryDoctor_SSN)...
2. Consider the following relations: Doctor(SSN, FirstName, LastName, Specialty,YearsOfExperience, PhoneNum) Patient(SSN, FirstName, LastName, Address, DOB, PrimaryDoctor_SSN) Medicine(TradeName, UnitPrice, GenericFlag) Prescription(Prescription Id, Date, Doctor_SSN, Patient_SSN) Prescription_Medicine(Prescription Id, TradeName, NumOfUnits) Note: The Medicine relation has attributes, trade name, unit price, and whether or not the medicine is generic (True or False). a. Determine the functional dependencies that exist in each table given above.
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....
Using C++ programming. Thank you. Money class has the following member variables and functions. -member variable...
Using C++ programming. Thank you. Money class has the following member variables and functions. -member variable : dollar, cent -member function : setMoney(int dollar, int cent), printMoney(), operator overloading(+) Program the Money class so that the following function can be performed. int main(){ Money a, b, c; A.setMoney(10, 60); B.setMoney(20, 70; (a+b).printMoney(); c = a + b; c.printMoney(); }
java programming Create a class named Money. It should have member variables for Member Variables Store...
java programming Create a class named Money. It should have member variables for Member Variables Store dollars and cents as members (both should be int). They should be accessible from only inside the class. Methods  Write a default constructor that sets members to 0.  Write a two-parameter constructor that sets members to the parameter values.  Write get/set methods for the member variables.  Write an override method for toString. The returned string should be formatted as a...
(C++) You are given a file consisting of students’ names in the following form: lastName, firstName...
(C++) You are given a file consisting of students’ names in the following form: lastName, firstName middleName. (Note that a student may not have a middle name.) Write a program that converts each name to the following form: firstName middleName lastName. Your program must read each student’s entire name in a variable and must consist of a function that takes as input a string, consists of a student’s name, and returns the string consisting of the altered name. Use the...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT