SlideShare uma empresa Scribd logo
1 de 4
Baixar para ler offline
COP3330 Programming Assignment 2
Date and day of week calculator for 2013
Objectives
• Implement a simple class with public and private members and multiple
constructors.
• Gain a better understanding of the building and using of classes and objects.
• Practice problem solving using OOP.
Overview
You will implement a date and day of week calculator for the 2013 calendar year. The
calculator repeatedly reads in three numbers (in a line) from the standard input that are
interpreted as month dayofmonth daysafter, calculates the dates in the year and days of
week for the dates, and outputs the information. For example, input “1 1 31” is
interpreted as the following: the first 1 means the 1st month in the year, January; the
second 1 means the 1st
day in January; and the 31 means 31 days after the date January
1, 2013 (we assume the year is 2013 to simplify the program), which is February 1, 2013.
The program also calculates the days of week for each of the dates. More specifically,
for input “1 1 31”, the calculator should produce the following output:
“31 days after Tuesday, January 1, 2013 is Friday, February 1, 2013. “
The first input number must be from 1 to 12 representing the 12 months in 2013, the
second input number must be a day in the month (e.g. for 1-31 for January, 1-28 for
February, and so forth). The third number is larger than or equal to 0. The program
should report an error (and exit) if the input is incorrect. If a day is not in 2013, the
program should output that. Following are a sample input file (redirect to be the
standard input) and the corresponding output.
Input file:
1 1 20
1 1 31
2 1 0
1 1 32
4 5 0
2 1 28
1 1 59
6 10 100
7 20 300
12 20 2
Output:
20 days after Tuesday, January 1, 2013 is Monday, January 21, 2013.
31 days after Tuesday, January 1, 2013 is Friday, February 1, 2013.
0 days after Friday, February 1, 2013 is Friday, February 1, 2013.
32 days after Tuesday, January 1, 2013 is Saturday, February 2, 2013.
0 days after Friday, April 5, 2013 is Friday, April 5, 2013.
28 days after Friday, February 1, 2013 is Friday, March 1, 2013.
59 days after Tuesday, January 1, 2013 is Friday, March 1, 2013.
100 days after Monday, June 10, 2013 is Wednesday, September 18, 2013.
300 days after Saturday, July 20, 2013 is a date not in 2013.
2 days after Friday, December 20, 2013 is Sunday, December 22, 2013.
Details
1. This project has two components. The first component is to implement a date2013
class specified in the following. The second component is a driver program that uses
the date2013 class to realize the calculator.
2. The date2013 class should have two private data members of the int type, d and m
with m encoding the month (1 – January, 2-February, …) and d being the day in the
month. For example to represent April 5, d = 5, m = 4. To represent a date not in
2013, m=-1, d=-1.
3. The date2013 class should have the following public functions:
date2013();
date2013(int dd);
date2013(int dd, int mm);
void setdate(int dd, int mm);
void print();
void plusday(int days);
4. The default constructor date2013() should set the default date of the object to be
January 1, 2013.
5. The parameter for the constructor with 1 parameter date2013(int dd) ranges from 1
to 365 (the code should report error and exit if the parameter is not in the range)
and is day of year for the date in 2013. The constructor converts day of year to
month and day of month. For example the 70th
day of the year is March 11: the
constructor should make m =3 and d = 11 when date2013(70) is invoked.
6. For the two parameter constructor date2013(int dd, int mm), you just need to make
sure that month (mm) and day (dd) are legitimate and set d = dd, and m = dd. If
either the day or the month is not legitimate, the code should report error and exit.
7. Setdate is similar to the two parameter constructor.
8. The print() function calculates the day of week for the date2013 object and output
to the standard output the date in the form of ‘dayofweek, month day, 2013’. For
example, when the object have d=1, m=1, the print should output “Tuesday, January
1, 2013”. For a date not in 2013 (m=-1 and d =-1), this routine should output “a date
not in 2013”.
9. The plusday(int days) function modifies the m and d for the new date, which is days
after the current date.
10. You should declare the class in a file called proj2.h; and the implement of the class
(class functions) in a file called proj2.cpp. You should have a statement ‘#include
“proj2.h”’ in proj2.cpp. You should test your implementation using the provided
date2013_test.cpp. To compile the code: ‘g++ proj2.cpp date2013_test.cpp’.
11. Once your date2013 class is tested correctly, you should write a driver program
called proj2_driver.cpp that reads in lines of three numbers as specified earlier and
generates the corresponding output as specified using the date2013 class. The driver
is very small (about 20 lines of code) performing the basic IO.
Submission
The due time for this assignment is May 29 (Wendesday), 2013. 11:59pm.
Name your program as proj2.h, proj2.cpp, proj2_driver.cpp. Tar all of your files for this
assignment (which should include at least four files proj1.cpp and bug_fixing_log.txt),
name the tar file yourlastname_firstinitial_proj2.tar and submit the tar file in
blackboard. The bug fixing log file must follow the template given.
Grading policy
The program must work on linprog. O point for programs with any g++ compiler error on
linprog. You will need to track compiling errors that you fixed by yourselves in a log for
fixed compiler bugs that needs to have at least two entries for 5 points/each entry (10
points max) that are different from those in the bug fixing log in project 1.
• Program with no compiler error (20 points)
• Log for fixed compiler bugs (10 points)
• Implementation of the date2013 class, tested by a program similar to
date2013_test.cpp (55 points)
o Default constructor and print (program able to print the default date, first
output line for date2013_test.cpp) (20 points)
o Constructor with one parameter, second/third output line (10 points).
The 10 points include error reporting points.
o Constructor with 2 parameters, fourth and fifth output line (10 points).
The 10 points include error reporting points.
o setdate() function, sixth output line (5 points)
o plusday() function, sixth to eighth output lines (10 points)
• Correct proj2_driver.cpp (15 points)
Hints
1. Start the project as soon as possible.
2. You should first create proj2.h and have an empty implementation in proj2.cpp for
each member function with the body of the function containing one line
cout << “XXXX function has not been implemented.n” ;
3. You should then compile the proj2.cpp and date2013_test.cpp and run the code.
From here, you can implement and test one function after another until the whole
class is implemented.
4. You should then implement the default construct date2013(), and write a simple
print() function that simply prints out the value of d and m.
5. After that you can implement the member functions in the following order
date2013(int dd, int mm), setdate(int dd, int mm), date2013(int dd), print(),
playday(int days). Remember to compile and run the program at least once
everytime you add one function.
6. You should write the driver only after your date2013 class is completely correct.
7. To compute the date for X days after the current date, one can convert the current
date into the day of year by adding up all days in the previous months and the day in
the month, add X to the day of year to obtain the new day of the year, and then
convert it back to the month and day of month representation (using the reverse
computation process to convert current date to day of year). For example, the day of
year for April 5 is daysinmonth[Jan] + daysinmonth[Feb] + daysinmonth[March] + 5.
8. To compute day of the week for a given date, one can have the following encoding:
0 – Sunday, 1-Monday, 2-Tuesday, 3-Wednesday, 4-Thursday, 5-Friday, 6-Saturday.
Using this encoding, one can first convert the date into day of year, let it be X. Since
January 1, 2013 is a Tuesday, the encoded day of week = (2 + X -1) % 7.
9. For reference, a sample proj2.cpp has 125 lines of code, proj2_driver.cpp has 23
lines.

Mais conteúdo relacionado

Destaque

Destaque (10)

Lo48
Lo48Lo48
Lo48
 
E7
E7E7
E7
 
T1
T1T1
T1
 
P1
P1P1
P1
 
T3
T3T3
T3
 
P3
P3P3
P3
 
P4
P4P4
P4
 
Lo27
Lo27Lo27
Lo27
 
P5
P5P5
P5
 
E9
E9E9
E9
 

Semelhante a Lo17

Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docxWalter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docxmelbruce90096
 
Excel DATEDIFF Function
Excel DATEDIFF FunctionExcel DATEDIFF Function
Excel DATEDIFF FunctionExcel
 
MS Project - Lesson #1A - Basics of Project Scheduling - Part 1O.docx
MS Project - Lesson #1A - Basics of Project Scheduling - Part 1O.docxMS Project - Lesson #1A - Basics of Project Scheduling - Part 1O.docx
MS Project - Lesson #1A - Basics of Project Scheduling - Part 1O.docxrosemarybdodson23141
 
Spreadsheet Date & Time Functions
Spreadsheet Date & Time FunctionsSpreadsheet Date & Time Functions
Spreadsheet Date & Time FunctionsAnjan Mahanta
 
C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]MomenMostafa
 
SessionSeven_WorkingWithDatesandTime
SessionSeven_WorkingWithDatesandTimeSessionSeven_WorkingWithDatesandTime
SessionSeven_WorkingWithDatesandTimeHellen Gakuruh
 
(2) cpp abstractions abstraction_and_encapsulation
(2) cpp abstractions abstraction_and_encapsulation(2) cpp abstractions abstraction_and_encapsulation
(2) cpp abstractions abstraction_and_encapsulationNico Ludwig
 
Create bar chart report for p6 r8.3 using bi publisher 11g - Oracle Primavera...
Create bar chart report for p6 r8.3 using bi publisher 11g - Oracle Primavera...Create bar chart report for p6 r8.3 using bi publisher 11g - Oracle Primavera...
Create bar chart report for p6 r8.3 using bi publisher 11g - Oracle Primavera...p6academy
 
(1) cpp abstractions user_defined_types
(1) cpp abstractions user_defined_types(1) cpp abstractions user_defined_types
(1) cpp abstractions user_defined_typesNico Ludwig
 
Math-Presentation(Math survivor).pptx
Math-Presentation(Math survivor).pptxMath-Presentation(Math survivor).pptx
Math-Presentation(Math survivor).pptxstolenMovie
 
AIN102D Access date functions sample queries
AIN102D Access date functions sample queriesAIN102D Access date functions sample queries
AIN102D Access date functions sample queriesDan D'Urso
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming  EECS 1.docxProject 2Project 2.pdfIntroduction to Programming  EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docxwkyra78
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxAASTHA76
 
C- Programming Assignment practice set 2 solutions
C- Programming Assignment practice set 2 solutionsC- Programming Assignment practice set 2 solutions
C- Programming Assignment practice set 2 solutionsAnimesh Chaturvedi
 
Using Microsoft Project 2003
Using Microsoft Project 2003Using Microsoft Project 2003
Using Microsoft Project 2003pparakh
 
Project Scope and Business Objective WorksheetA. General Informa.docx
Project Scope and Business Objective WorksheetA. General Informa.docxProject Scope and Business Objective WorksheetA. General Informa.docx
Project Scope and Business Objective WorksheetA. General Informa.docxbriancrawford30935
 

Semelhante a Lo17 (20)

Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docxWalter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
Walter Krohn;2,12,1891;15,3,2015Paula Nightingale;3,3,1933;2.docx
 
Excel DATEDIFF Function
Excel DATEDIFF FunctionExcel DATEDIFF Function
Excel DATEDIFF Function
 
MS Project - Lesson #1A - Basics of Project Scheduling - Part 1O.docx
MS Project - Lesson #1A - Basics of Project Scheduling - Part 1O.docxMS Project - Lesson #1A - Basics of Project Scheduling - Part 1O.docx
MS Project - Lesson #1A - Basics of Project Scheduling - Part 1O.docx
 
Lecture1
Lecture1Lecture1
Lecture1
 
Spreadsheet Date & Time Functions
Spreadsheet Date & Time FunctionsSpreadsheet Date & Time Functions
Spreadsheet Date & Time Functions
 
L12 complexity
L12 complexityL12 complexity
L12 complexity
 
C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]
 
SessionSeven_WorkingWithDatesandTime
SessionSeven_WorkingWithDatesandTimeSessionSeven_WorkingWithDatesandTime
SessionSeven_WorkingWithDatesandTime
 
(2) cpp abstractions abstraction_and_encapsulation
(2) cpp abstractions abstraction_and_encapsulation(2) cpp abstractions abstraction_and_encapsulation
(2) cpp abstractions abstraction_and_encapsulation
 
Create bar chart report for p6 r8.3 using bi publisher 11g - Oracle Primavera...
Create bar chart report for p6 r8.3 using bi publisher 11g - Oracle Primavera...Create bar chart report for p6 r8.3 using bi publisher 11g - Oracle Primavera...
Create bar chart report for p6 r8.3 using bi publisher 11g - Oracle Primavera...
 
(1) cpp abstractions user_defined_types
(1) cpp abstractions user_defined_types(1) cpp abstractions user_defined_types
(1) cpp abstractions user_defined_types
 
Math-Presentation(Math survivor).pptx
Math-Presentation(Math survivor).pptxMath-Presentation(Math survivor).pptx
Math-Presentation(Math survivor).pptx
 
AIN102D Access date functions sample queries
AIN102D Access date functions sample queriesAIN102D Access date functions sample queries
AIN102D Access date functions sample queries
 
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming  EECS 1.docxProject 2Project 2.pdfIntroduction to Programming  EECS 1.docx
Project 2Project 2.pdfIntroduction to Programming EECS 1.docx
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
 
C- Programming Assignment practice set 2 solutions
C- Programming Assignment practice set 2 solutionsC- Programming Assignment practice set 2 solutions
C- Programming Assignment practice set 2 solutions
 
Using Microsoft Project 2003
Using Microsoft Project 2003Using Microsoft Project 2003
Using Microsoft Project 2003
 
Object-Oriented Programming Using C++
Object-Oriented Programming Using C++Object-Oriented Programming Using C++
Object-Oriented Programming Using C++
 
Project Scope and Business Objective WorksheetA. General Informa.docx
Project Scope and Business Objective WorksheetA. General Informa.docxProject Scope and Business Objective WorksheetA. General Informa.docx
Project Scope and Business Objective WorksheetA. General Informa.docx
 
Gantt chart discuss 3
Gantt chart discuss 3Gantt chart discuss 3
Gantt chart discuss 3
 

Mais de lksoo

Mais de lksoo (13)

Lo43
Lo43Lo43
Lo43
 
Lo12
Lo12Lo12
Lo12
 
L10
L10L10
L10
 
L9
L9L9
L9
 
L8
L8L8
L8
 
L7
L7L7
L7
 
L6
L6L6
L6
 
L5
L5L5
L5
 
L4
L4L4
L4
 
L3
L3L3
L3
 
L2
L2L2
L2
 
L1
L1L1
L1
 
E6
E6E6
E6
 

Último

Deconstructing Gendered Language; Feminist World-Making 2024
Deconstructing Gendered Language; Feminist World-Making 2024Deconstructing Gendered Language; Feminist World-Making 2024
Deconstructing Gendered Language; Feminist World-Making 2024samlnance
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comthephillipta
 
Best Call girls in Lucknow - 9548086042 - with hotel room
Best Call girls in Lucknow - 9548086042 - with hotel roomBest Call girls in Lucknow - 9548086042 - with hotel room
Best Call girls in Lucknow - 9548086042 - with hotel roomdiscovermytutordmt
 
RAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAKRAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAKedwardsara83
 
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...akbard9823
 
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...anilsa9823
 
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...anilsa9823
 
The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)thephillipta
 
Jeremy Casson - Top Tips for Pottery Wheel Throwing
Jeremy Casson - Top Tips for Pottery Wheel ThrowingJeremy Casson - Top Tips for Pottery Wheel Throwing
Jeremy Casson - Top Tips for Pottery Wheel ThrowingJeremy Casson
 
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶delhimunirka444
 
FULL NIGHT — 9999894380 Call Girls In Saket | Delhi
FULL NIGHT — 9999894380 Call Girls In Saket | DelhiFULL NIGHT — 9999894380 Call Girls In Saket | Delhi
FULL NIGHT — 9999894380 Call Girls In Saket | DelhiSaketCallGirlsCallUs
 
Storyboard short: Ferrarius Tries to Sing
Storyboard short: Ferrarius Tries to SingStoryboard short: Ferrarius Tries to Sing
Storyboard short: Ferrarius Tries to SingLyneSun
 
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort ServiceYoung⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Servicesonnydelhi1992
 
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...anilsa9823
 
AaliyahBell_themist_v01.pdf .
AaliyahBell_themist_v01.pdf             .AaliyahBell_themist_v01.pdf             .
AaliyahBell_themist_v01.pdf .AaliyahB2
 
Young⚡Call Girls in Lajpat Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Lajpat Nagar Delhi >༒9667401043 Escort ServiceYoung⚡Call Girls in Lajpat Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Lajpat Nagar Delhi >༒9667401043 Escort Servicesonnydelhi1992
 
Bobbie goods coloring book 81 pag_240127_163802.pdf
Bobbie goods coloring book 81 pag_240127_163802.pdfBobbie goods coloring book 81 pag_240127_163802.pdf
Bobbie goods coloring book 81 pag_240127_163802.pdfMARIBEL442158
 
Lucknow 💋 Call Girls Service Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8...
Lucknow 💋 Call Girls Service Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8...Lucknow 💋 Call Girls Service Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8...
Lucknow 💋 Call Girls Service Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8...anilsa9823
 
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...akbard9823
 

Último (20)

Deconstructing Gendered Language; Feminist World-Making 2024
Deconstructing Gendered Language; Feminist World-Making 2024Deconstructing Gendered Language; Feminist World-Making 2024
Deconstructing Gendered Language; Feminist World-Making 2024
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
 
RAJKOT CALL GIRL 76313*77252 CALL GIRL IN RAJKOT
RAJKOT CALL GIRL 76313*77252 CALL GIRL IN RAJKOTRAJKOT CALL GIRL 76313*77252 CALL GIRL IN RAJKOT
RAJKOT CALL GIRL 76313*77252 CALL GIRL IN RAJKOT
 
Best Call girls in Lucknow - 9548086042 - with hotel room
Best Call girls in Lucknow - 9548086042 - with hotel roomBest Call girls in Lucknow - 9548086042 - with hotel room
Best Call girls in Lucknow - 9548086042 - with hotel room
 
RAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAKRAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAK
 
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
 
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
 
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
 
The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)
 
Jeremy Casson - Top Tips for Pottery Wheel Throwing
Jeremy Casson - Top Tips for Pottery Wheel ThrowingJeremy Casson - Top Tips for Pottery Wheel Throwing
Jeremy Casson - Top Tips for Pottery Wheel Throwing
 
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
 
FULL NIGHT — 9999894380 Call Girls In Saket | Delhi
FULL NIGHT — 9999894380 Call Girls In Saket | DelhiFULL NIGHT — 9999894380 Call Girls In Saket | Delhi
FULL NIGHT — 9999894380 Call Girls In Saket | Delhi
 
Storyboard short: Ferrarius Tries to Sing
Storyboard short: Ferrarius Tries to SingStoryboard short: Ferrarius Tries to Sing
Storyboard short: Ferrarius Tries to Sing
 
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort ServiceYoung⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Uttam Nagar Delhi >༒9667401043 Escort Service
 
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
 
AaliyahBell_themist_v01.pdf .
AaliyahBell_themist_v01.pdf             .AaliyahBell_themist_v01.pdf             .
AaliyahBell_themist_v01.pdf .
 
Young⚡Call Girls in Lajpat Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Lajpat Nagar Delhi >༒9667401043 Escort ServiceYoung⚡Call Girls in Lajpat Nagar Delhi >༒9667401043 Escort Service
Young⚡Call Girls in Lajpat Nagar Delhi >༒9667401043 Escort Service
 
Bobbie goods coloring book 81 pag_240127_163802.pdf
Bobbie goods coloring book 81 pag_240127_163802.pdfBobbie goods coloring book 81 pag_240127_163802.pdf
Bobbie goods coloring book 81 pag_240127_163802.pdf
 
Lucknow 💋 Call Girls Service Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8...
Lucknow 💋 Call Girls Service Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8...Lucknow 💋 Call Girls Service Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8...
Lucknow 💋 Call Girls Service Lucknow ₹7.5k Pick Up & Drop With Cash Payment 8...
 
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
Hazratganj / Call Girl in Lucknow - Phone 🫗 8923113531 ☛ Escorts Service at 6...
 

Lo17

  • 1. COP3330 Programming Assignment 2 Date and day of week calculator for 2013 Objectives • Implement a simple class with public and private members and multiple constructors. • Gain a better understanding of the building and using of classes and objects. • Practice problem solving using OOP. Overview You will implement a date and day of week calculator for the 2013 calendar year. The calculator repeatedly reads in three numbers (in a line) from the standard input that are interpreted as month dayofmonth daysafter, calculates the dates in the year and days of week for the dates, and outputs the information. For example, input “1 1 31” is interpreted as the following: the first 1 means the 1st month in the year, January; the second 1 means the 1st day in January; and the 31 means 31 days after the date January 1, 2013 (we assume the year is 2013 to simplify the program), which is February 1, 2013. The program also calculates the days of week for each of the dates. More specifically, for input “1 1 31”, the calculator should produce the following output: “31 days after Tuesday, January 1, 2013 is Friday, February 1, 2013. “ The first input number must be from 1 to 12 representing the 12 months in 2013, the second input number must be a day in the month (e.g. for 1-31 for January, 1-28 for February, and so forth). The third number is larger than or equal to 0. The program should report an error (and exit) if the input is incorrect. If a day is not in 2013, the program should output that. Following are a sample input file (redirect to be the standard input) and the corresponding output. Input file: 1 1 20 1 1 31 2 1 0 1 1 32 4 5 0 2 1 28 1 1 59 6 10 100 7 20 300 12 20 2
  • 2. Output: 20 days after Tuesday, January 1, 2013 is Monday, January 21, 2013. 31 days after Tuesday, January 1, 2013 is Friday, February 1, 2013. 0 days after Friday, February 1, 2013 is Friday, February 1, 2013. 32 days after Tuesday, January 1, 2013 is Saturday, February 2, 2013. 0 days after Friday, April 5, 2013 is Friday, April 5, 2013. 28 days after Friday, February 1, 2013 is Friday, March 1, 2013. 59 days after Tuesday, January 1, 2013 is Friday, March 1, 2013. 100 days after Monday, June 10, 2013 is Wednesday, September 18, 2013. 300 days after Saturday, July 20, 2013 is a date not in 2013. 2 days after Friday, December 20, 2013 is Sunday, December 22, 2013. Details 1. This project has two components. The first component is to implement a date2013 class specified in the following. The second component is a driver program that uses the date2013 class to realize the calculator. 2. The date2013 class should have two private data members of the int type, d and m with m encoding the month (1 – January, 2-February, …) and d being the day in the month. For example to represent April 5, d = 5, m = 4. To represent a date not in 2013, m=-1, d=-1. 3. The date2013 class should have the following public functions: date2013(); date2013(int dd); date2013(int dd, int mm); void setdate(int dd, int mm); void print(); void plusday(int days); 4. The default constructor date2013() should set the default date of the object to be January 1, 2013. 5. The parameter for the constructor with 1 parameter date2013(int dd) ranges from 1 to 365 (the code should report error and exit if the parameter is not in the range) and is day of year for the date in 2013. The constructor converts day of year to month and day of month. For example the 70th day of the year is March 11: the constructor should make m =3 and d = 11 when date2013(70) is invoked. 6. For the two parameter constructor date2013(int dd, int mm), you just need to make sure that month (mm) and day (dd) are legitimate and set d = dd, and m = dd. If either the day or the month is not legitimate, the code should report error and exit. 7. Setdate is similar to the two parameter constructor. 8. The print() function calculates the day of week for the date2013 object and output to the standard output the date in the form of ‘dayofweek, month day, 2013’. For example, when the object have d=1, m=1, the print should output “Tuesday, January
  • 3. 1, 2013”. For a date not in 2013 (m=-1 and d =-1), this routine should output “a date not in 2013”. 9. The plusday(int days) function modifies the m and d for the new date, which is days after the current date. 10. You should declare the class in a file called proj2.h; and the implement of the class (class functions) in a file called proj2.cpp. You should have a statement ‘#include “proj2.h”’ in proj2.cpp. You should test your implementation using the provided date2013_test.cpp. To compile the code: ‘g++ proj2.cpp date2013_test.cpp’. 11. Once your date2013 class is tested correctly, you should write a driver program called proj2_driver.cpp that reads in lines of three numbers as specified earlier and generates the corresponding output as specified using the date2013 class. The driver is very small (about 20 lines of code) performing the basic IO. Submission The due time for this assignment is May 29 (Wendesday), 2013. 11:59pm. Name your program as proj2.h, proj2.cpp, proj2_driver.cpp. Tar all of your files for this assignment (which should include at least four files proj1.cpp and bug_fixing_log.txt), name the tar file yourlastname_firstinitial_proj2.tar and submit the tar file in blackboard. The bug fixing log file must follow the template given. Grading policy The program must work on linprog. O point for programs with any g++ compiler error on linprog. You will need to track compiling errors that you fixed by yourselves in a log for fixed compiler bugs that needs to have at least two entries for 5 points/each entry (10 points max) that are different from those in the bug fixing log in project 1. • Program with no compiler error (20 points) • Log for fixed compiler bugs (10 points) • Implementation of the date2013 class, tested by a program similar to date2013_test.cpp (55 points) o Default constructor and print (program able to print the default date, first output line for date2013_test.cpp) (20 points) o Constructor with one parameter, second/third output line (10 points). The 10 points include error reporting points. o Constructor with 2 parameters, fourth and fifth output line (10 points). The 10 points include error reporting points. o setdate() function, sixth output line (5 points) o plusday() function, sixth to eighth output lines (10 points)
  • 4. • Correct proj2_driver.cpp (15 points) Hints 1. Start the project as soon as possible. 2. You should first create proj2.h and have an empty implementation in proj2.cpp for each member function with the body of the function containing one line cout << “XXXX function has not been implemented.n” ; 3. You should then compile the proj2.cpp and date2013_test.cpp and run the code. From here, you can implement and test one function after another until the whole class is implemented. 4. You should then implement the default construct date2013(), and write a simple print() function that simply prints out the value of d and m. 5. After that you can implement the member functions in the following order date2013(int dd, int mm), setdate(int dd, int mm), date2013(int dd), print(), playday(int days). Remember to compile and run the program at least once everytime you add one function. 6. You should write the driver only after your date2013 class is completely correct. 7. To compute the date for X days after the current date, one can convert the current date into the day of year by adding up all days in the previous months and the day in the month, add X to the day of year to obtain the new day of the year, and then convert it back to the month and day of month representation (using the reverse computation process to convert current date to day of year). For example, the day of year for April 5 is daysinmonth[Jan] + daysinmonth[Feb] + daysinmonth[March] + 5. 8. To compute day of the week for a given date, one can have the following encoding: 0 – Sunday, 1-Monday, 2-Tuesday, 3-Wednesday, 4-Thursday, 5-Friday, 6-Saturday. Using this encoding, one can first convert the date into day of year, let it be X. Since January 1, 2013 is a Tuesday, the encoded day of week = (2 + X -1) % 7. 9. For reference, a sample proj2.cpp has 125 lines of code, proj2_driver.cpp has 23 lines.