In: Computer Science
In C++
Instructions:
Use a void function to print the following message (should be in welcome function)
Welcome to the Event Scheduling program
create 3 int arrays with 3 positions (one array for days one array for moths and one array for years) (should be in main)
Create a file that contains the following (you can just create the file or write the file in the program)
1 / 26 / 2021
12 / 13 / 2020
2 / 1 / 2021
Read the file and place the day, month and year for each date into the appropriate array (should be in main)
ask the user to type a date in the following format (should be in main)
<day> / <month> / <year>
Determine whether the date the user entered is the same as any of the dates in your arrays (should be in dateCompare function)
If the date does not match any of the dates in the arrays then print the following message:
<day> / <month> / <year> is available. We will add you to our calendar (should be in printMessage function)
If the date does match any of the dates in the array then print the following message:
<day> / <month> / <year> is not available. Please try again with a different date (should be in printMessage function)
Ask the user if they want to enter more dates(should be in main)
if the user answers “yes” then repeat steps 5-8 (should be in main)
if the user answer “no” then print the following message: Thanks for using the Event Scheduling program(should be in main)
if the user types anything else then print the following message:
Did not follow instructions(should be in main)
Here are the functions you need
Function name | Parameters | Return Type
heading | N/A | void
dateCompare | days,months,years,day,month,year | bool
printMessage | day,month,year | void
EXAMPLE
Welcome to the Event Scheduling program
Please enter a date in the following format: <day> / <month> / <year> (example: 2 / 15 / 2020)
1 / 26 / 2021
1 / 26 / 2021 is not available. Please try again with a different date.
Would you like to enter more dates? (Enter yes/no)
yes
Please enter a date in the following format: <day> / <month> / <year> (example: 2 / 15 / 2020)
1 / 27 / 2021
1 / 27 / 2021 is available. We will add you to our calendar.
Would you like to enter more dates? (Enter yes/no)
no
Thanks for using the Event Scheduling program
Hi please find the c++ code, will add the dateCompare function
there is power cut happening here, once it is back i will update
the dateCompare function as well please find the rest of the
solutiob below
Thanks
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
void printMessage(string s){
cout << s << endl;
}
void welcome(){
printMessage("Welcome to the Event Scheduling program");
}
bool dateCompare(string s, int date[], int month[], int year[]
){
}
int main() {
//welcome function
welcome();
//3 arrays (one array for days one array for moths and
one array for years)
int date[3] = {23,13,1};
int month[3] = {1,12,2};
int year[3] = {2021,2020,2021};
string input = "yes";
while (input != "no"){
if (input == "yes"){
printMessage("Please enter a date in the following format:
<day> / <month> / <year> (example: 2 / 15 /
2020)");
//takes input
date
getline(cin,input);
bool result =
dateCompare(input,date,month,year);
string
msg="";
if
(result){
msg = input + " is not available. Please try
again with a different date.";
}
else{
msg = input + " is available. We will add you to
our calendar.";
}
printMessage(msg);
}
else{
//add more if
you like
string help =
"Did not follow instructions \nHere are the functions you need \n
dateCompare \n printMessage";
printMessage(help);
}
printMessage("Would you like to
enter more dates? (Enter yes/no)");
//get yes/no
getline(cin,input);
}
printMessage("Thanks for using the Event Scheduling
program");
return 0;
}