Question

P3.1 Given the following date class interface: class date private int month ll1-12 int day; ll 1-28, 29, 30, 31 depending on month & year int year 4-digit, e.g., 2017 public: date(): Default constructor (investigate; find what it is used for) Postcondition: the newly declared date object is initialized to 01/01/2000 date (int mm, int dd, int yyyy): Second constructor Postcondition: the newly declared data object is initialized to void setDate(int mm, int dd, int yyyy); Postcondition: set the contents of the calling date object to the values passed to the function void displayDatev10; Postcondition: display the calling date object in mm/dd/yyyy format, e.g., 02/22/2017 void displayDateV20 Postcondition: display the calling datecobject in the format like: February 22, 2017 int date &dobj); compares the two date objects: the calling one the dobj that is passed to the function Postcondition: retums -1, 0, or lif the calling date object if less than, equal to, or greater than dobj, respectively. Your are asked to: .Implement all six member functions 2 Write a maino function containing C+ code to test all six member functions. Note that for the compareDates function, you must test all three possibilities! Format you program output so make it easily readable.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <string.h>
#include <stdio.h>

char string1[] = "2012-12-06 14:28:51";
char string2[] = "2011-12-06 14:28:51";

int main( void )
{
   char tmp[20];
   int result;

   printf( "Compare strings:\n   %s\n   %s\n\n\n", string1, string2 );
   result = strcmp( string1, string2 );

   if( result > 0 )        strcpy( tmp, "greater than" );
   else if( result < 0 )   strcpy( tmp, "less than" );
   else    strcpy( tmp, "equal to" );

   printf( "   strcmp:   String 1 is %s string 2\n\n", tmp );

   return 0;
}
Add a comment
Know the answer?
Add Answer to:
Given the following date class interface: class date {private: int month;//1 - 12 int day;//1 -...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • public class Date { private int month; private int day; private int year; /** default constructor...

    public class Date { private int month; private int day; private int year; /** default constructor * sets month to 1, day to 1 and year to 2000 */ public Date( ) { setDate( 1, 1, 2000 ); } /** overloaded constructor * @param mm initial value for month * @param dd initial value for day * @param yyyy initial value for year * * passes parameters to setDate method */ public Date( int mm, int dd, int yyyy )...

  • In C++ Consider the following Date class: #include <iostream> using namespace std; class MyDate { private:...

    In C++ Consider the following Date class: #include <iostream> using namespace std; class MyDate { private: int month, day, year; public: MyDate() {setDate(2,27,2006);} MyDate(int, int, int); void setDate(int mm, int dd, int yyyy); void showDate(); }; MyDate::MyDate(int mm, int dd, int yyyy) { month = mm; day = dd; year = yyyy; }; void MyDate::setDate(int mm, int dd, int yyyy) { month = mm; day = dd; year = yyyy; }; void MyDate::showDate() { cout << "The date is "...

  • Create a class named Date in C++ Class has 3 private data items (name the data...

    Create a class named Date in C++ Class has 3 private data items (name the data items month, day, year) int month int day int year Member functions ‘getters’   a getter for each data item Use ‘get’ and the data items name The data item name must be capitalized Return the data item Example: int getMonth()        {return month;} ‘setters’   a setter for each data item Use ‘set’ and the data items name The data item name must be capitalized Change...

  • Public: bool older(wine &); returns false otherwise int ageDifference(wine &); Postcondition: ret...

    public: bool older(wine &); returns false otherwise int ageDifference(wine &); Postcondition: returns the difference in years produced (must be a positive value) between the calling object and the one explicitly passed to the function bool costlier(wine &); // Postcondition: returns true if the calling objectis"costlier than the object explicitly passed to the function returns false otherwise void inputValuesForwineobj); / Prompts the user to enter type, year, and cost of the calling wine object (a bottle) // Postcondition: data members of...

  • HW_8b - Famous People - One class used by another class - This exercise requires the...

    HW_8b - Famous People - One class used by another class - This exercise requires the declaration of two classes: o Famous People O Date - 5 Files are required: o Date.h o Date.cpp o Famous People.h o Famous People.cpp o main.cpp File: Date.h Private data members: O _month o _day 0 year - Public member functions: o Default constructor • Assign O's to all three data members. o Overloaded constructor • Three integer values are passed as arguments from...

  • Design and implement a C++ class called Date that has the following private member variables month...

    Design and implement a C++ class called Date that has the following private member variables month (int) day (nt) . year (int Add the following public member functions to the class. Default Constructor with all default parameters: The constructors should use the values of the month, day, and year arguments passed by the client program to set the month, day, and year member variables. The constructor should check if the values of the parameters are valid (that is day is...

  • The rest of question 4: object. Make sure that the implementation of class Employee2 includes all...

    The rest of question 4: object. Make sure that the implementation of class Employee2 includes all necessary revisions to all members functions that appeared in class Employee implementation. Heres a link for the class Employee: http://www.cs117.ghriga.com/blog/2017/10/07/practice-4/ de the program and determine its output if the user enters-2 B) Trace the program and determine its output if the u C) Trace the program and determine its output if the ts D) Trace the program and determine its output if the user...

  • The class dateType is designed to implement the date in a program, but the member function...

    The class dateType is designed to implement the date in a program, but the member function setDate and the constructor do not check whether the date is valid before storing the date in the data members. Rewrite the definitions of the function setDate and the constructor so that the values for the month, day, and the year are checked before storing the date into the data members. Add a function member, isLeapYear, to check whether a year is a leap...

  • C++ Programming Step 1. Design a new ADT that implements a class named Date, add 3 private member variables month, day, year along with their appropriate public constructor / getter / setter member fu...

    C++ Programming Step 1. Design a new ADT that implements a class named Date, add 3 private member variables month, day, year along with their appropriate public constructor / getter / setter member functions inside Date.h and Date.cpp. Step 2. Design another ADT that implements a class named Watch, add 3 private member variables hour, minute, second, along with their appropriate public constructor / getter / setter member functions inside Watch.h and Watch.cpp. Step 3. Next, implement the additional SmartWatch...

  • For this project a Date class(specifiedin the file Project_10.h) will be constructed and all function definitions will be written in the file Project_10.cpp. A makefileis provided to compile this project. The file Project_10_main.cppcontainsthe main fun

    Project_10_base_files.zipMakefile (2).txtProject_10_main 1.JPGProject_10_main 2.JPGProject_10_main 3.JPGProject_10 h.JPGProject_10 cpp.JPGAny C++ technique covered in Chapters 1 through 12is allowedexcept for global variablesYou are not allowed to use any global variables.If necessary, global constants may be used.Project 10DescriptionFor this project a Date class(specifiedin the file Project_10.h) will be constructed and all function definitions will be written in the file Project_10.cpp.  A makefileis provided to compile this project.  The file Project_10_main.cppcontainsthe main functionthat is used to run the program.On Canvas, download the files Project_10.h, Project_10_main.cpp...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT