2021/9/27 上午11:00 EECS 183 Project 2: Birthdays | p2-birthdays https://eecs183.github.io/p2-birthdays/#p2-birthdays 1/31 p2-birthdays EECS 183 Project 2: Birthdays Project Due Friday, October 1, 2021, 11 59pm Eastern Direct autograder link You will write an application to identify the day of the week on which you were born. Along the way, you will write functions that compute whether a year is a leap year and which day of the week (e.g. Monday, Tuesday) a particular date falls on. This project is significantly more difficult than Project 1 and you can expect it to take 2 to 3 times longer to complete. By completing this project, you will learn to: Develop programs that are divided into functions Compile programs that are not yet complete by using stubs Verify the correctness of functions by writing test cases Distinguish between invalid and bad input when creating test cases Implement functions based on a specification and RME comment Create algorithms that use conditionals and loops Translate mathematical formulas to code You will apply the following skills you learned in lecture: Lecture 3 Call math functions like floor() and ceil() . Lecture 4 Call functions with multiple parameters 2021/9/27 上午11:00 EECS 183 Project 2: Birthdays | p2-birthdays https://eecs183.github.io/p2-birthdays/#p2-birthdays 2/31 Use return statements to provide a result from a function Lecture 5 Create function declarations to allow calls to a function before its code is provided in a function definition Execute the cin algorithm to determine how a given user input will be stored into variables Lecture 6 Use if , else , and else if to conditionally execute code Interpret RME comments Lecture 7 Write event-controlled loops using while Combine loops with cin to continue reading until the user is finished Lecture 8 Write count-controlled loops using for Getting Started Starter Files You can download the starter files using this link. The IDE setup tutorials for Visual Studio and XCode include a video about how to set up a project using the starter files. You can access the tutorals here: Visual Studio XCode Make sure there are 3 files in your project: birthdays.cpp , test.cpp , and start.cpp . Submission and Grading Submit your code to the autograder here. You receive 4 submits each day and your best overall submission counts as your score. You have one bonus submission that you can use to get a 5th submission on any one day. You can find where the files you need to submit are on your computer using these steps from Project 1. You will submit two files, which must be called birthdays.cpp and test.cpp . Here is a grade breakdown: 60 points: correctness. Implement functions in birthdays.cpp and create a birthday calculator. To what extent does your code implement the features required by our 2021/9/27 上午11:00 EECS 183 Project 2: Birthdays | p2-birthdays https://eecs183.github.io/p2-birthdays/#p2-birthdays 3/31 specification? To what extent is your code consistent with our specifications and free of bugs? 10 points: testing. To what extent is your code tested? Implement the testing functions and submit them via the test.cpp file. See the Testing section for more details. 10 points: style. To what extent is your code written well? To what extent is your code readable? We will only look at your birthdays.cpp when determining your style grade. Consult the EECS 183 Style Guide and check the Style Checklist at the end of this project sʼ specification for some tips! The deadline is Friday, October 1, 2021 at 8PM Eastern, with an automatic extension until 11 59PM. If your last submission is on Wednesday, September 29 by 11 59PM, you will receive a 5% bonus. If your last submission is on Thursday, September 30 by 11 59PM, you will receive a 2.5% bonus. You have 3 late days that you can use any time during the semester for projects. There are 3 late days total, not 3 per project. To use a late day, submit to the autograder after the deadline. It will prompt you about using one of your late day tokens. There are more details about late days in the syllabus. Understanding the Distribution Code birthdays.cpp: Starter code for the application you will write in this project. Holds the definitions of required functions and the implementations of a couple functions. We have stubbed all required functions for you. test.cpp: Testing functions for your birthdays.cpp implementation. Holds the definitions of required testing functions. We have stubbed all required functions for you. start.cpp: This file contains the main() function for your program, which allows you to run either the birthdays application or your test suite. You do not need to modify this file or submit it to the autograder. Stubbing functions means adding the minimal necessary code to make a function compile. For example, some of the functions in birthdays.cpp have return types of bool . We have added return false in those functions so that they will compile even if you have not implemented all the functions yet. Be sure to remove our stubs when you write your own implementation of the function. Testing Your Setup Once you have created a project, you should be able to compile and run the distribution code. We have included a main() function in start.cpp which will allow you to run either your tests or the birthdays application. 2021/9/27 上午11:00 EECS 183 Project 2: Birthdays | p2-birthdays https://eecs183.github.io/p2-birthdays/#p2-birthdays 4/31 EECS 183 Project 2 Menu Options ------------------------------- 1) Execute testing functions in test.cpp 2) Execute birthdays() function in birthdays.cpp Choice --> 1 Now testing function isGregorianDate() 9/2/2019: Expected: 1, Actual: 0 1/31/1001: Expected: 0, Actual: 0 ... The first test case currently fails because the isGregorianDate() function is not fully implemented yet. How to get help Most students in EECS 183 need help from staff and faculty multiple times each project. Weʼre here for you! Many more people need help with Project 2 than with Project 1. If your question is about the specification or about something about the project in general, Piazza is the fastest place to get help. You can also ask about your particular code, but in a private post. You can get 1-1 help over a video call by signing up for office hours at eecsoh.org. You can find instructions at eecs183.org > Office Hours. Collaboration Policy We want students to learn from and with each other, and we encourage you to collaborate. We also want to encourage you to reach out and get help when you need it. You are encouraged to: Give or receive help in understanding course concepts covered in lecture or lab. Practice and study with other students to prepare for assessments or exams. Consult with other students to better understand project specifications. Discuss general design principles or ideas as they relate to projects. Help others understand compiler errors or how to debug parts of their code. To clarify the last item, you are permitted to look at another student sʼ code to help them understand what is going on with their code. You are not allowed to tell them what to write for their code, and you are not allowed to copy their work to use in your own solution. If you are at all unsure whether your collaboration is allowed, please contact the course staff via the admin form before you do anything. We will help you determine if what youʼre thinking of doing is in the spirit of collaboration for EECS 183. The following are considered Honor Code violations: 2021/9/27 上午11:00 EECS 183 Project 2: Birthdays | p2-birthdays https://eecs183.github.io/p2-birthdays/#p2-birthdays 5/31 Submitting othersʼ work as your own. Copying or deriving portions of your code from othersʼ solutions. Collaborating to write your code so that your solutions are identifiably similar. Sharing your code with others to use as a resource when writing their code. Receiving help from others to write your code. Sharing test cases with others if they are turned in as part of your solution. Sharing your code in any way, including making it publicly available in any form (e.g. a public GitHub repository or personal website). The full collaboration policy can be found in the syllabus. Problem Statement In this project, you will develop an application to calculate information regarding specific dates in the past and future, which will allow you to find out what day any given birthday was on. Your program will provide a menu, implemented using a loop, to obtain user input and calculate birthdays. Here is an example of what the execution of your final application will look like: EECS 183 Project 2 Menu Options ------------------------------- 1) Execute testing functions in test.cpp 2) Execute birthdays() function in birthdays.cpp Choice --> 2 ******************************* Birthday Calculator ******************************* Menu Options ------------ 1) Determine day of birth 2) Print the next 10 leap years 3) Finished Choice --> 1 Enter your date of birth format: month / day / year --> 1 / 25 / 2000 You were born on a: Tuesday Have a great birthday!!! Menu Options ------------ 2021/9/27 上午11:00 EECS 183 Project 2: Birthdays | p2-birthdays https://eecs183.github.io/p2-birthdays/#p2-birthdays 6/31 1) Determine day of birth 2) Print the next 10 leap years 3) Finished Choice --> 3 **************************************************** Thanks for using the Birthday Calculator **************************************************** Development Cycle with Functions In Project 1, you had to divide the program into pieces so you could test each part individually. In Project 2 and later, the program is already divided into functions in the starter code which you can use as the parts to work on. Functions make it much easier to test your code than it was for Project 1. In this section, we will walk through how to write your program one function at a time by writing tests first. The functions in a program call each other, and it is easiest to start with the functions that do not call any other functions. For example, in this project, print10LeapYears() will call isLeapYear() , so it makes sense to complete isLeapYear() before print10LeapYears() . We will be able to test isLeapYear() before we write the code that actually uses it in our program. The order you write the functions will be different than the order they appear in birthdays.cpp. We will follow very similar steps to Project 1 to write the isLeapYear() function. Step 1: Make examples of input and output There are two places to look for information about each function: first this specification, and second the RME attached to the function declaration. The specification is useful for a high- level overview, and the RME is useful for the very specific details. Here is a link to the section in this specification about isLeapYear() . Here is its RME from birthdays.cpp : /** * Requires: year is a Gregorian year * Modifies: nothing * Effects: returns 'true' if the year is a leap year * otherwise returns 'false' */ bool isLeapYear(int year); In this case, we are able to find: In the specification In the RME 2021/9/27 上午11:00 EECS 183 Project 2: Birthdays | p2-birthdays https://eecs183.github.io/p2-birthdays/#p2-birthdays 7/31 The definition of a leap year What assumptions you can make about the inputs (that year will always be Gregorian) Examples of leap years and non-leap years What the input and output types of the function are Like we did for Project 1, weʼll a table of example inputs and outputs. The examples from the spec are already filled in for you: Input (int) Output (bool) 1768 true 1800 false 2000 true [more examples you think of] Can 1740 be a valid input to isLeapYear() ? The answer is no, because the REQUIRES clause states that year must be a Gregorian year (see isGregorianDate() for details about Gregorian years). That means that we do not need to check inside isLeapYear() whether year is Gregorian or not – we can make the assumption the programmer will never give an invalid year as input. There is more discussion about these kinds of assumptions you can make in the Invalid vs. Bad Input section later in the specification. Step 2: Write Test Cases In your IDE, pull up the test.cpp file. We have provided a test_isLeapYear() function that you can use to write your tests inside. Here sʼ an example of how to do it. Your goal is not just to call the function, but to use cout statements that will give you proof the function works properly. void test_isLeapYear() { cout << "Now testing function isLeapYear()" << endl; // Remember that true becomes 1 and false becomes 0 // when you send it to cout cout << "1768: Expected 1, Actual: " << isLeapYear(1768) << endl; cout << "1800: Expected 0, Actual: " << isLeapYear(1800) << endl; // continue writing tests in this style } 2021/9/27 上午11:00 EECS 183 Project 2: Birthdays | p2-birthdays https://eecs183.github.io/p2-birthdays/#p2-birthdays 8/31 Donʼt forget to add a call to test_isLeapYear() in the startTests() function at the top of tests.cpp ! The important parts of these test cases are that they: