Write a program to go through your address book and print the names and phone numbers Solution

$19.99
0 ratings

Everyone has at least one friend who always remembers everyone’s birthday. Write a program to go through your address book and print the names and phone numbers of all people who have birthdays on that day, so you can give them a call.

For this program you MUST use the following struct, the classand the non member function

struct Date { int month; int day;

};

classDatetype

{ public:

void set(intnew_month, intnew_day);

// date set according to the incoming parameters

// this function calls the check_date function.

intget_month(); // accessor function

intget_day();

private:

voidcheck_date();

Date bday;

};

bool compare(Datetype d1, Datetype d2);

// returns true if d1 and d2 represent same month and day;

//otherwise returns false

Input: Today’s month and day (from the keyboard); and a list of names, phone numbers, and birthdates (from the data file). Entries in the file - Friendfile.dat are in the form

PROUD NORMA 555-256-1256 3 5 HANDSOME HANLY 800-133-2255 8 15

CLUMSY NORA 740-123-4567 3 5

GLAMOROUS PENNY 760-345-2211 1 25

MONEYBAG JOE 740-589-9876 4 29

Etc..

Output:The names and phone numbers of any friends whose birthdays are on that day.

Sample output is as follows: If no one has a birthday on that day, just print the message

“No birthdays today”

Enter today’s month and day 3 5

PROUD NORMA 555-256-1256

CLUMSY NORA 740-123-4567

Hints:

 Create a separate directory for this assignment.

 First you need to declare two objects of the Datetype. – one store the month and day from the data file and the other to store month and day from the keyboard.

 Declare the first,last and the phone_number as sting variables and month and day as integer variables in the function main to store the values read from the data file.

 Then you enter the today’s date (month and day) from the keyboard and call the mutator function (set function) to set the values. This function calls the check_date function.

 The check_date function exit the program if month or day is invalid. (pg 562)

 You need to use the dotoperator in the set function definition and the check_date function definition and in accessor functions because the bday has two members of the structtype.

 Now start with awhile(file_stream>> first >> last >> ...) loop in the main that will read the first line of data in the data file. Call the function set again with the values from the data file. (same as above)

 Then call the compare function to compare the two days (month and day). If they are equal print the first, last, phone number to the screen with left justifications.

 You can open, check for fail and close the input file in the main.

 Don’t forget to include the necessary libraries.

Electronic submission /home/kmgsubm/bin/2400submit -p 6

Submit only the source code and the data file. Also turn in your source code on Friday, November 14th.

Scoring for Assignment 6

2 points comments (name, date, good introduction to the program, declaration comments etc)

8 points function main

15 points correct implementation of member non member function in the class 4 points style - indenting, formatting etc. 1 point source cod

I want this!
Size
1.39 KB
Copy product URL
$19.99

Write a program to go through your address book and print the names and phone numbers Solution

0 ratings
I want this!