Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Time class, which holds following information: hour minute second Creat

ID: 3804393 • Letter: C

Question

Create a Time class, which holds following information:

hour

minute

second

Create a date class, which holds the following information:

day

month

year

Create Constructors for both classes–

Create an application that uses both Time and Date classes

A minimum of 3 constructors including default constructor

Getters and setters

Helper methods

toString() method

toUniversalTime()

toStandardTime()

Validate the data in the setters.

Create 2 instances of Time and Date

Use a Scanner to read in the information

print Time and Date in both Universal Time and Standard Time

Flow Chart for each program, make sure to use software to do the flow charts (use correct symbols)

Make sure your code if well commented

Explanation / Answer

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

class Date
{
public:
   void setDate(int month, int day, int year);
   void getDate(int &mm, int &dd, int &yyyy);
   void dateDisplay();
   Date(int month, int day, int year);
   Date();

private:
   int dd;
   int mm;
   int yyyy;
};

void Date::setDate(int month, int day, int year)
{
   if (month >= 1 && month <= 12) //Makes sure the month stay between 1 and 12.
   {
       mm = month;
   }
   if (day >= 01 && day <= 31) // Makes sure the day stay between 1 - 31
   {
       dd = day;
   }
   if (year >= 1)
   {
       yyyy = year;
   }
}
Date::Date(int month, int day, int year)
{
   setDate(month, day, year); //Constructor to show date.
}

void Date::dateDisplay()
{
   if (mm < 10)
   {
       cout << "0" << mm << "."; //Makes the mm have a 0 in front if below 10 (Readability).
   }
   else
   {
       cout << mm << ".";   //If above 10, no zero (Readability).
   }
   if (dd < 10)
   {
       cout << "0" << mm << "."; //If dd is below ten, give first 0 (Readability).
   }
   else
   {
       cout << dd << "."; // else none needed.
   }
   if (yyyy < 10)
   {
       cout << "00" << yyyy; //If yyyy is less than 10, give two 0s (Readability).
   }
   else if (yyyy < 100)
   {
       cout << "0" << yyyy; //If yyyy is less than 100, give one 0 (Readability).
   }

   else
   {
       cout << yyyy; // else none needed.
   }
}

class Time
{
public:
   void setTime(int hour, int minute);
   void getTime(int &hr, int &minute);
   void displayTime();
   Time(int hour, int minute);
   Time();

private:
   int hr;
   int min;
};

void Time::setTime(int hour, int minute)
{
   if (hour >= 1 && hour <= 12) //Makes sure the hour stay between 1 and 12.
   {
       hr = hour;
   }
   else
   {
       hr = 0;
   }
   if (minute >= 00 && minute < 60) // Makes sure the minute stay between 0 and 60
   {
       min = minute;
   }
   else
   {
       min = 0;
   }
}

void Time::displayTime()
{
   if (hr < 10)
   {
       cout << "0" << hr << ":"; //Makes the hr have a 0 in front if below 10.
   }
   else
   {
       cout << hr << ":";   //If above 10, no zero.
   }
   if (min < 10)
   {
       cout << ":0" << min; //If min is below ten, give first 0.
   }
   else
   {
       cout << min; // else none needed.
   }
}

Time::Time(int hour, int minute)
{
   setTime(hour, minute); //Constructor to show time.
}

Time::Time()
{
   //Do Nothing
}


void timeDisplay(Time time)
{
   time.setTime(10,17);
   cout << "The STARTING time in Eastern Standard Time is: ";
   time.displayTime();
   cout << "." << endl << endl;
}

void dateDisplay(Date date)
{
   date.setDate(1,1,2000);
   cout << "The __ Date is: ";
   date.dateDisplay();
   cout << "." << endl << endl;

}

class Event1
{
public:
   void setEvent1Info(string eventName, int hour, int min, int month, int day, int year);
   void displayEvent1();
   Event1 (string eventName, int hour, int min, int month, int day, int year);
   Event1();
private:
   Time eventTime;
   Date eventDate;
   string eventName;
};

void Event1::setEvent1Info(string eventName, int hour, int minute, int month, int day, int year)
{

}
void displayEvent(Event1 event1)
{
   event1.setEvent("Thanksgiving",12,00,03,26,2017);
   //cout << eventName;
   event1.displayEvent();
   cout << endl << endl;
}

void main()
{
   Time time;
   timeDisplay(time);

   Date date;   //error
   dateDisplay(date);   //error

   Event1 event1; // error
   displayEvent1(event1); //error
}