Question

In: Computer Science

In C++ Create a class that simulates a school calendar for a course and has a...

In C++

Create a class that simulates a school calendar for a course and has a warner that provides the school administration with the option of warning students when the last day is that a student is permitted to drop the course. (Allow administrators to warn or not, as they wish. Do not make this a required function.)

You will assume in this calendar that there are 12 months in a year, 4 weeks in a month, and 7 days in a week. You can represent any day by 3 numbers. For example 12/3/2 would represent the 2nd day in the 3rd week of the 12th month. In this class you should:

  • Store a calendar day in terms of month, week, and day. (You should represent the month from 1 to 12, week from 1 to 4, and day from 1 to 7.)

  • Initialize the calendar to a specified day. (For example, you can initialize the calendar to 1/1/1.)

  • Allow the calendar to increment to the next day. (Hint: You need to take into account things such as whether the calendar is at the 3rd week, 6th day. Then you may need to consider iterated if statements.) In addition, you need to prevent the possibility of going beyond the 12th month, 4th week, and 7th day.

  • Set the warner and have the warner print out "TODAY IS THE LAST DAY TO DROP THE COURSE" when the set date is reached. (Hint: You may wish to create a private function that provides the wished-for printout when the date is reached and the warner is on.)

  • Display the present date.

  • Use the class in a program that uses the functions requiring displaying of time and setting of the warner.

Include 2 constructors. One constructor should be the default constructor that will initialize the object to 1/1/1. The second constructor should take parameters for months, weeks, and days. Both constructors will provide the private members with the date. In addition, have both constructors set the warner as off. (You will need a Boolean attribute that determines whether the warner is on or off. The administrators have the option of using the warner. They do not have to provide a warning to students if they do not wish to. In fact, the constructor should set the default as the warner is off and will not provide a warning to students.) The function or method you use to set the warner will set the warner on. (Hint: Have the class also have attribute of month, week, and day and the ability to be on or off with a Boolean variable for the warner.)

Output: Students should develop the output for this assignment to be as clear and concise as possible. Provide as much detail as possible in regards to the dates and corresponding calendar timeline.

Solutions

Expert Solution

#include<iostream>
#include<string>

using namespace std;

//schoolCalender class
class schoolCalender
{
//private variables
int month;
int week;
int day;
bool warner;

public:
//Default constructor
schoolCalender(){
  month=1;
  week=1;
  day=1;
  warner=false;
}

//Parameterised constructor
schoolCalender(int month, int week,int day) {
  month=month;
  week=week;
  day=day;
  warner=false;
}
//To set date
void setDate(int month, int week,int day){
  this->month=month;
  this->week=week;
  this->day=day;

}
//To increment date
void incrementDate(){
  //calling method to increment the date
  incrementMonth();
  incrementWeek();
  incrementDay();
}

void incrementMonth(){
  if(month==12)
   month=1;
  else
   month++;
}
void incrementWeek()
{
  if(week==4)
   week=1;
  else
   week++;
}
void incrementDay()
{
  
  if(day==7)
   day=1;
  else
   day++;
}
//checking two dates are equal or not
bool isLastDate(schoolCalender sc )
{
  if(this->month==sc.month && this->week==sc.week && this->day==sc.day )
  {
   warner=true;
   return true ;
  }
  else
   false;
}


//returns waner value
bool returnWarner()
{
  return warner;
}
//Display date
void display(){
  cout<<"MM/WW/DD:"<<month<<"/"<<week<<"/"<<day;
}
};

int main(){
//school date
schoolCalender schoolDate;
schoolDate.setDate(12,4,3);

//school last date
schoolCalender lastDate;
lastDate.setDate(12,4,3);


//cheking whether the school date is last date
schoolDate.isLastDate(lastDate);

//if waner boolean value is true then this message will print
if(schoolDate.returnWarner())
  cout<<"TODAY IS THE LAST DAY TO DROP THE COURSE"<<endl;

//Incrementing the date

cout<<"Date before incrementing school date   ";
schoolDate.display();
cout<<"\nDate after incrementing school date ";
schoolDate.incrementDate();
schoolDate.display();
cout<<endl;
system("pause");

return 0;

}

OUTPUT:

TODAY IS THE LAST DAY TO DROP THE COURSE

Date before incrementing school date MM/WW/DD:12 / 4 / 3

Date after incrementing school date MM/WW/DD:1 / 1 / 4

press any key to continue . . . . .

HOPE U LIKE THIS ANSWER


Related Solutions

Create a ShoppingCart class in java that simulates the operation of a shopping cart. The ShoppingCart...
Create a ShoppingCart class in java that simulates the operation of a shopping cart. The ShoppingCart instance should contain a BagInterface implementation that will serve to hold the Items that will be added to the cart. Use the implementation of the Item object provided in Item.java. Note that the price is stored as the number of cents so it can be represented as an int (e.g., an Item worth $19.99 would have price = 1999). Your shopping cart should support...
Create a ShoppingCart class in java that simulates the operation of a shopping cart. The ShoppingCart...
Create a ShoppingCart class in java that simulates the operation of a shopping cart. The ShoppingCart instance should contain a BagInterface implementation that will serve to hold the Items that will be added to the cart. Use the implementation of the Item object provided in Item.java. Note that the price is stored as the number of cents so it can be represented as an int (e.g., an Item worth $19.99 would have price = 1999). Using the CLASSES BELOW Your...
Create a ShoppingCart class in java that simulates the operation of a shopping cart. The ShoppingCart...
Create a ShoppingCart class in java that simulates the operation of a shopping cart. The ShoppingCart instance should contain a BagInterface implementation that will serve to hold the Items that will be added to the cart. Use the implementation of the Item object provided in Item.java. Note that the price is stored as the number of cents so it can be represented as an int (e.g., an Item worth $19.99 would have price = 1999). **PLEASE USE THE CLASSES BELOW***...
Java Coding Background You will create a Java class that simulates a water holding tank. The...
Java Coding Background You will create a Java class that simulates a water holding tank. The holding tank can hold volumes of water (measured in gallons) that range from 0 (empty) up to a maximum. If more than the maximum capacity is added to the holding tank, an overflow valve causes the excess to be dumped into the sewer system. Assignment The class will be named HoldingTank. The class attributes will consist of two int fields – current and maxCapacity....
write cplus programs for exercises Drink Machine Simulator Create a class that simulates and manages a...
write cplus programs for exercises Drink Machine Simulator Create a class that simulates and manages a soft drink machine. Information on each drink type should be stored in a structure that has data members to hold the drink name, the drink price, and the number of drinks of that type currently in the machine. The class should have an array of five of these structures, initialized with the following data. Drink Name      Cost   Number in Machine Cola       1.00  ...
can someone code this problem please? Introduction Students will create a C++ program that simulates a...
can someone code this problem please? Introduction Students will create a C++ program that simulates a Pokemon battle mainly with the usage of a while loop, classes, structs, functions, pass by reference and arrays. Students will be expected to create the player’s pokemon and enemy pokemon using object-oriented programming (OOP). Scenario You’ve been assigned the role of creating a Pokemon fight simulator between a player’s Pikachu and the enemy CPU’s Mewtwo. You need to create a simple Pokemon battle simulation...
C++ Create a program that simulates a coin being flipped. Ask the user to guess between...
C++ Create a program that simulates a coin being flipped. Ask the user to guess between heads and tails. Let the user input 0 for heads and 1 for tails. Use a random generator to get random guesses every time. If the user guesses correctly, give them 1pt. Use a counter and initialize it to 0.   If the user does not guess correctly, subtract a point. Create a menu that allows the user to continue guessing, view the current score...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
Create a C program that simulates time-sharing in the operating system. Please follow the instructions provided:...
Create a C program that simulates time-sharing in the operating system. Please follow the instructions provided: a) Use a circular queue. b) It is required that the process be inputted by the user. The user must input the process name and the duration in seconds, and for this simulation let the user input 5 processes. c) As this requires process name and duration, use an array of structures. d) To simulate time-sharing, following the algorithm presented below: d.1) Use the...
Create a working C# Program that will accept an input and has the following class. areaCircle...
Create a working C# Program that will accept an input and has the following class. areaCircle – computes the area of the circle volumeCube – computes the volume of a cube perimeterTraingle – computes the perimeter of a triangle surfaceAreaRect – computes the surface area of a rectangle *You may usePass by Value and/or Pass by Reference *Using ConsoleApp
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT