#ifndef Time_h #define Time_h #include #include using namespace std; class myTime{ private: int hours; int minutes; int seconds; string AM_PM; public: myTime(); myTime(int a,int b,int c,string e); void sethours(int a); void setminutes(int b); void setseconds(int c); int gethours(); int getminutes(); int getseconds(); string getAM_PM(); void print(); void ticktack(); }; #endif #include "time.h" myTime::myTime(){ cout<<"hours:"<>hours; if(hours<1 || hours>12) hours=12; cout<<"minutes:"<>minutes; if(minutes<0 || minutes>59) minutes=0; cout<<"seconds:"<>seconds; if(seconds<0 || seconds>59) seconds=0; cout<<"is it AM or PM:"<>x; if(x=="AM"||x=="PM") AM_PM=x; else AM_PM="AM"; } myTime::myTime(int a,int b,int c,string e){ sethours(a); setminutes(b); setseconds(c); AM_PM=e;} void myTime::sethours(int a){ if(a<1||a>12) a=12; else hours=a; } void myTime::setminutes(int b){ if(b<0||b>59) b=0; else minutes=b; } void myTime::setseconds(int c){ if(c<0||c>59) c=0; else seconds=c; } int myTime::gethours(){ return hours; } int myTime::getminutes(){ return minutes; } int myTime::getseconds(){ return seconds; } string myTime::getAM_PM(){ return AM_PM; } void myTime::ticktack(){ seconds++; if(seconds==60) { minutes++; seconds=0; } if(minutes==60) { hours++; minutes=0; } if(hours==13) { hours=1; } if((hours==12 && minutes==0 && seconds==0)&&(AM_PM=="AM")){ AM_PM="PM"; } elseif((hours==12 && minutes==0 && seconds==0)&&(AM_PM=="PM")){ AM_PM="AM"; } } void myTime::print(){ cout<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
i already have this code for myTime:
#ifndef Time_h
#define Time_h
#include <iostream>
#include <string>
using namespace std;
class myTime{
private:
int hours;
int minutes;
int seconds;
string AM_PM;
public:
myTime();
myTime(int a,int b,int c,string e);
void sethours(int a);
void setminutes(int b);
void setseconds(int c);
int gethours();
int getminutes();
int getseconds();
string getAM_PM();
void print();
void ticktack();
};
#endif
#include "time.h"
myTime::myTime(){
cout<<"hours:"<<endl;
cin>>hours;
if(hours<1 || hours>12)
hours=12;
cout<<"minutes:"<<endl;
cin>>minutes;
if(minutes<0 || minutes>59)
minutes=0;
cout<<"seconds:"<<endl;
cin>>seconds;
if(seconds<0 || seconds>59)
seconds=0;
cout<<"is it AM or PM:"<<endl;
string x;
cin>>x;
if(x=="AM"||x=="PM")
AM_PM=x;
else AM_PM="AM";
}
myTime::myTime(int a,int b,int c,string e){
sethours(a);
setminutes(b);
setseconds(c);
AM_PM=e;}
void myTime::sethours(int a){
if(a<1||a>12)
a=12;
else hours=a;
}
void myTime::setminutes(int b){
if(b<0||b>59)
b=0;
else minutes=b;
}
void myTime::setseconds(int c){
if(c<0||c>59)
c=0;
else seconds=c;
}
int myTime::gethours(){
return hours;
}
int myTime::getminutes(){
return minutes;
}
int myTime::getseconds(){
return seconds;
}
string myTime::getAM_PM(){
return AM_PM;
}
void myTime::ticktack(){
seconds++;
if(seconds==60)
{
minutes++;
seconds=0;
}
if(minutes==60)
{
hours++;
minutes=0;
}
if(hours==13)
{
hours=1;
}
if((hours==12 && minutes==0 && seconds==0)&&(AM_PM=="AM")){
AM_PM="PM";
}
elseif((hours==12 && minutes==0 && seconds==0)&&(AM_PM=="PM")){
AM_PM="AM";
}
}
void myTime::print(){
cout<<hours<<":"<<minutes<<":"<<seconds<<AM_PM<<endl;
}
 
Q1:

Implement class student that represents a student object as follows.

Use separate implementation, with different header to store the class declaration.

Data members:

1) An object of type myTime called RegTime.

  1. 2)  String variable the represent the name of the student.

  2. 3)  A student ID that should be incremented automatically according to the number of objects

    created so far.

Member Functions:

4) The class should have a default and two parameterized constructors; the first parameterized constructor take five parameters: 3 integers to represent the day, month, and year of the mytime object, and 2 strings to represent “am/pm” and the name; the second constructor should take two parameters: a Time object and a string.

5) The class should be able to print to the standard output information about itself.

Q2: 

Implement class course defined as follows.

Use separate implementation, with different header to store the class declaration.

  1. 1)  The class should encapsulate information about:
    - the name of course (String),
    - creation time of the course (myTime) ,
    - number of students enrolled in the course (integer) (must be greater than 1), if the user provides a

    value less than 1, assume the default value. - An array of Students of maximum size of 10.

  2. 2)  The class should contain parameterized constructor .

  3. 3)  The class should contain getters for each of the name, creation date and the number of

    students.

  4. 4)  The class should contain setter for the creation date.

  5. 5)  The class should be able to print to the standard output all of its details.Q3:

    1. 1)  define Non member function called findMaxStudents, that takes two course objects and returns the name of the course with the highest number of students enrolled in it.

    2. 2)  define Non member function called DelayCourseTime, that that takes a course object. It prints its creation time. Then add extra 5 second to that Time and then set the new Time back to the course object and then reprint the time again.

    In the main function, do the following:

    1. 1)  define two course objects, fill the data needed for the objects as follow:
      the first object: name is c++ lab, and have 3 students.
      the second object: name is Java lab, and have 4 students.
      Create the necessary time objects and student arrays needed for the object creation.

    2. 2)  call the function findMaxStudents for the two course objects to print the name of the course with the highest number of students enrolled in it.

    3. call the function DelayCourseTime using first course object.

      sample output in the attachment image

Sample output:
the name of the course of the highest number of enrolled students is :
Java lab
the creation time is
the time is: 10 : 59 : 55 pm
the creation time after 5 seconds advanced
the time is: 11 : 0 : 0 pm
Transcribed Image Text:Sample output: the name of the course of the highest number of enrolled students is : Java lab the creation time is the time is: 10 : 59 : 55 pm the creation time after 5 seconds advanced the time is: 11 : 0 : 0 pm
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education