1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
natulia [17]
3 years ago
6

Date Class Constructor – assigns fields to appropriate formal parameter – using the setters so error checking will occur. The co

nstructor with no formal parameters should have no statements in the body of the function. Accessors – return the appropriate fields Setters setMonth – assigns the field to the formal parameter. Error checks the formal parameter to make sure it is a valid month number. If it isn’t a valid month, it sets the month to 1. setDay – assigns the field to the formal parameter. Error checks to make sure the day being passed in is a valid day for the month the object has (ex: January can only be 1-31). You do NOT have to check for leap year – just make sure February is 1-29. If the day is invalid, it sets the day to be 1 setYear – assigns the field to the formal parameter. Error checks the formal parameter to make sure it is not negative. If it is it sets the year to be 1900. toString – creates a string in the format M/D/Y and returns it. The following allows you to concatenate a string with an integer. Use this information to create and return the string in the format M/D/Y. string ans = to_string(month) + "/"; Date -day: int -month: int -year: int +Date() +Date(month:int, day:int, year:int) +getMonth(): int +getDay(): int +getYear():int +setMonth(month:int):void +setDay(day:int) :void +setYear(year:int) :void +toString():string

Computers and Technology
1 answer:
lara31 [8.8K]3 years ago
4 0

Answer:

Check the explanation

Explanation:

#include <iostream>

#include <fstream>

#include <string>

#include <iomanip>

#include "Date.h"

#include "Person.h"

using namespace std;

const int MAXSIZE = 50;

// Prototypes go here

int loadArray(string fileName, Person students[]);

void sortByName(Person students[], int numE);

void printStudentReport(Person students[], int numE);

int main()

{

Person students[MAXSIZE];

int numE;

string fileName;

cout << "Enter the file name: ";

cin >> fileName;

numE = loadArray(fileName, students);

cout << endl;

cout << "Before Sort: " << endl;

printStudentReport(students, numE);

sortByName(students, numE);

cout << endl;

cout << "After Sort: " << endl;

printStudentReport(students, numE);

return 0;

}

int loadArray(string fileName, Person students[]){

ifstream in;

in.open(fileName.c_str());

if(in.fail())

return -1;

int n=0;

string fname, lname;

int month, day, year;

while(!in.eof()){

in>>fname>>lname>>month>>day>>year;

students[n] = Person(fname, lname, Date(month, day, year));

n++;

}

return n;

}

void sortByName(Person students[], int numE){

for(int i=0; i<numE; i++){

for(int j=i+1; j<numE; j++){

if(students[i].getLastName()>students[j].getLastName()){

Person temp = students[i];

students[i] = students[j];

students[j] = temp;

}

}

}

}

void printStudentReport(Person students[], int numE){

for(int i=0; i<numE; i++){

cout<<students[i].getLastName()<<", "<<students[i].getFirstName()<<"\t\t"<<students[i].getDateofBirth().toString()<<endl;

}

}

Person.h

#include<iostream>

#include<string>

using namespace std;

#include "Date.h"

#ifndef PERSON_H

#define PERSON_H

class Person{

private:

string firstName;

string lastName;

public:

Date dateOfBirth;

Person();

Person(string firstName, string lastName, Date dob);

string getFirstName();

string getLastName();

Date getDateofBirth();

void setFirstName(string fname);

void setLastName(string lname);

void setDateOfBirth(Date dob);

void setDateOfBirth(int month, int day, int year);

};

#endif

Person.cpp

#include "Person.h"

Person::Person(){

firstName = "";

lastName = "";

}

Person::Person(string firstName, string lastName, Date dob){

this->firstName = firstName;

this->lastName = lastName;

setDateOfBirth(dob.getMonth(), dob.getDay(), dob.getYear());

}

string Person::getFirstName(){

return firstName;

}

string Person::getLastName(){

return lastName;

}

Date Person::getDateofBirth(){

return dateOfBirth;

}

void Person::setFirstName(string fname){

firstName = fname;

}

void Person::setLastName(string lname){

lastName = lname;

}

void Person::setDateOfBirth(Date dob){

setDateOfBirth(dob.getMonth(), dob.getDay(), dob.getYear());

}

void Person::setDateOfBirth(int month, int day, int year){

dateOfBirth.setMonth(month);

dateOfBirth.setDay(day);

dateOfBirth.setYear(year);

}

Date.h

#include<iostream>

#include<string>

using namespace std;

#ifndef DATE_H

#define DATE_H

class Date{

private:

int day;

int month;

int year;

public:

Date();

Date(int month, int day, int year);

int getMonth();

int getDay();

int getYear();

void setMonth(int month);

void setDay(int day);

void setYear(int year);

string toString();

};

#endif

Date.cpp

#include "Date.h"

Date::Date(){

month = 1;

day = 1;

year = 1900;

}

Date::Date(int month, int day, int year){

this->month = month;

this->day = day;

this->year = year;

}

int Date::getMonth(){

return month;

}

int Date::getDay(){

return day;

}

int Date::getYear(){

return year;

}

void Date::setMonth(int month){

this->month = month;

}

void Date::setDay(int day){

this->day = day;

}

void Date::setYear(int year){

this->year = year;

}

string Date::toString(){

string ans = to_string(month)+"/";

ans += to_string(day)+"/";

ans += to_string(year);

return ans;

}

Kindly check the code output below.

You might be interested in
What is the term for the era created by the digital revolution?<br>​
puteri [66]

Answer:

The Digital Revolution also marks the beginning of the Information Era. The Digital Revolution is sometimes also called the Third Industrial Revolution.

Explanation:

Hope this Helps.

5 0
3 years ago
I need the answer ASAP. I’ll mark brainliest if right
Kisachek [45]

Answer:

copy or repeat

Explanation:

7 0
3 years ago
The concept/theory where computer generated animation (especially humans) that is TOO life-like they become uncomfortable to us
Zolol [24]

Answer:

The concept/theory where computer generated animation (especially humans) that is TOO life-like they become uncomfortable to us as viewers instead of likeable cartoons is known as Uncanny valley

Explanation:

The uncanny valley is a concept that was introduced in the 1970s by Masahiro Mori. It is used to describe when a computer generated animated figure bears too much of a resemblance to humans, to the extent that the person viewing it may feel a sense of unease. The animated figure appearing almost human would likely elicit cold and eerie feelings in viewers.

7 0
3 years ago
Read 2 more answers
A _______________ is a particular type of network that uses circuits that run over the Internet but that appears to the user to
ArbitrLikvidat [17]

Answer:

A virtual privte network is a particular type of network that uses circuits that run over the Internet but that appears to the user to be a private network.

5 0
2 years ago
What are the 5 general terms of the fair use rule
Andrews [41]

the purpose and character of your use.

the nature of the copyrighted work.

the amount and substantiality of the portion taken, and.

the effect of the use upon the potential market

In its most general sense, a fair use is any copying of copyrighted material done for a limited and “transformative” purpose, such as to comment upon, criticize, or parody a copyrighted work. Such uses can be done without permission from the copyright owner

the nature of the copyrighted work; the amount and substantiality of the portion used in relation to the copyrighted work as a whole; and. the effect of the use upon the potential market for or value of the copyrighted work

uwu hope dis halpz!

5 0
3 years ago
Other questions:
  • Show the contents of a queue after the following operations are performed. Assume the queue is initially empty. enqueue(45); enq
    6·1 answer
  • An investigator obtains consent and HIPAA authorization from subjects to review their medical records and HIV status. He plans t
    8·1 answer
  • An ideal line length would include how many characters? A. 6570 B. 100 C. 100125 D. 4055
    8·1 answer
  • Edhesive 3.2 Lesson Practice question 1
    5·1 answer
  • Project manager George is defining project management to his team. How should he define project management in one sentence?
    7·1 answer
  • Given the business rule "an employee may have many degrees," discuss its effect on attributes, entities, and relationships. (Hin
    10·1 answer
  • "which type of network connects smart devices or consumer electronics within a range of about 30 feet (10 meters) and without th
    7·1 answer
  • Can someone solve this for me please? It’s part of an escape room.
    13·2 answers
  • What is the purpose of a Post Mortem Review? (5 points)
    5·1 answer
  • To find detailed information about the origin of an email message, look at the ________________.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!