Question
Problem Definition (in C++ language): Build a Date class and a main function to test it. Specifications We have provided the interface (declaration) for the
Problem Definition (in C++ language):
Build a Date class and a main function to test it.
Specifications
We have provided the interface (declaration) for the Date class: it is our "contract" with you: you have to implement everything it describes. The comments in the provided interface should be sufficient for you to understand the project (do not delete these comments in your Date declaration), without the need of any further documentation. But of course, as always, you can ask us any questions you may have on Campuswire.
Note: Placing the error messages into the constructors like is not necessarily a good way to handle constructor errors, but until you learn about exceptions in CS 14, it's the best we can do.
Private Member Functions
The member functions declared private, isLeap, daysPerMonth, name, number, are helper functions - member functions that will never be needed by a user of the class, and so do not belong to the public interface (which is why they are "private"). They are, however, needed by the interface functions (public member functions), which use them to test the validity of arguments and construct valid dates. For example, the constructor that passes in the month as a string will call the number function to assign a value to the unsigned member variable month.
isLeap: The rule for whether a year is a leap year is:
- (year % 4 == 0) implies leap year
- except (year % 100 == 0) implies NOT leap year
- except (year % 400 == 0) implies leap year
So, for instance, year 2000 is a leap year, but 1900 is NOT a leap year. Years 2004, 2008, 2012, 2016, etc. are all leap years. Years 2005, 2006, 2007, 2009, 2010, etc. are NOT leap years.
Output Specifications
Read the specifications for the print function carefully. The only cout statements within your Date member functions should be:
- the "Invalid Date" warnings in the constructors
- in your two print functions
Required Main Function
You must use the provided main function and global function getDate as they are here. You may not change these functions at all to pass the tests in submit mode.
//
#include
using namespace std;
void readData(const string&, vector
int main() { string userInputFile; vector
cin >> userInputFile;
readData(userInputFile, path, lift);
cout << endl << endl;
if(path.empty()) { while(path.empty() || (path.size() != lift.size())) { cout << "Enter a different file" << endl; cin >> userInputFile; readData(userInputFile, path, lift); } } while(!isOrdered(path)) { reorder(path, lift); }
while(validInput) { cout << "Enter flight path angle" << endl << "Enter 1337 to break the loop and exit" << endl; cout << "Do not enter a string value, only doubles or ints" << endl << endl; cin >> pathInput; if(pathInput == 1337) { validInput = false; } else if(pathInput < path.at(0) || pathInput > path.at(path.size() - 1)) { cout << "Enter a value in the data's range" << endl; cin >> pathInput; } else { liftCoefficient = interpolation(pathInput, path, lift); cout << "The lift coefficient for the flight path angle " << pathInput << " is: " << liftCoefficient << endl; } }
return 0; }
void readData(const string& fileInput, vector
dataFile.open(fileInput.c_str());
if(!dataFile.is_open()) { cout << "Error opening "; cout << "tunnel11.txt" << endl; exit(1); } while(dataFile >> temp1) { path.push_back(temp1); //dataFile takes in temp1 then pushes into path vector dataFile >> temp2; lift.push_back(temp2); //start reading again after whitespace, then push into lift }
dataFile.close(); }
double interpolation(double b, const vector
bool isOrdered(const vector
unsigned findMin(const vector
void reorder(vector
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started