Create a program that prompts the user to enter a year and t
Create a program that prompts the user to enter a year and the first day of the year. Year must not be 0. The first day of the year is number that represents the day of the week. Use 0 for Sunday, 1 for Monday, 2 for Tuesday, etc. Validate the user input values. The program displays the calendar by constructing the HTML table. See the sample outputs.
Your submission must demonstrate your solution in action. Each ZIP file should contain at least one HTML and JS file all in the same folder. Do not duplicate code, use functions to avoid this common issue in programming.
Action Items/Programming Requirements
The solution must use and deliver both an HTML and a JS file.
The JS file must be referenced in the <head> tag of the HTML document using the <script> tag to load your function so it can be called later on.
The solution should use a <script> in the <body> of the HTML to call the main calendar function.
The prompt() function must be used to gather all information from the user just as was done in the example screen shots. Do not use <input> tags or hard coded input values.
Declare local variables only. No global variables permitted. All JS files must use the strict directive at the top of the file. Strict declarative will allow the JavaScript Console in a browser to display an error for undeclared variables.
Note, if you declare variables inside the HTML <script> section, then you are using global variables.
Follow the input-process-output program model.
You should have at least these two functions.
The main function has the Input-Process-Output program structure. It prompt for user inputs, validate the user inputs, call function(s) to get the calendar HTML table string and displays the calendar. See the sample output.
calendar function takes three inputs, year, first day of the month and month. It constructs a HTML table that contains the calendar for the given month and year. Do not display the calendar in the calendar function. Instead returns the string containing the HTML calendar table.
You may need these utility/helper functions:
monthName function takes one input, month number and returns month name based on the month number. For example, if month is 1, then returns January. If month is 2, then returns February. If month is 12, then returns December.
isLeaprYear function takes one input, year and returns true if the given year is leap year, false otherwise.
daysInMonth function takes two inputs, year and month, and returns number of days in given month. Take leap year into consideration. For example, if month is 2 and year is 2016, then returns 29. If month is 2 and year is 2015, then returns 28. If month is 4 and year is 2014, then returns 30. And so forth.
Put the HTML and JS files in the same folder.
Try to make your solution look similar to the screen shots. It is acceptable to display each month calendar on each line. See the sample outputs for two different styles.
Put identifying information in your files: your name, assignment name/number term/class.Example for HTML:
<!-- YourName Lab 2 2015-FA-ITEC136 -->
Example for JS:
/**
* @author YourName
* Lab 2 - 2015-FA-ITEC 136
*/
THIS HAS TO BE IN HTML FORMAT WITH A JAVASCRIPT IN IT
Solution
#include < iostream > #include < cmath > using namespace std; int main () { float dwi; // Input data for day of week year began float dyi; // Input data for the day of the year double dayOfYear; // Output data for day of year bool numbersAreOK; // True if data is within the range of 1-366 // Prompt for what day of the week the year begins on cout << \"To represent what day the year began on, please enter a whole number from 0-6.\" \" \" \"0 representing Sunday, 6 representing Saturday. \" << endl; cin >> dwi; // Prompt for the day of the year cout << \" Please enter a whole number from 1-366 to represent the day of the year you wish to display.\" << endl; cin >> dyi; // Test Data if ( dwi < 0 || dwi > 6) numbersAreOK = false; cout << \"Invalid data, please try again.\" << endl; if ( dyi < 1 || dyi > 366) numbersAreOK = false; cout << \"Invalid Data, Please try again.\" << endl; if ( numbersAreOK = true) { // Calculate day of year double dayOfYear = (dwi + dyi--1)%7; // Print Day of Year if (dayOfYear == 0) cout << \"Sunday\" << endl; else if (dayOfYear == 1) cout << \"Monday\" << endl; else if (dayOfYear == 2) cout << \"Tuesday\" << endl; else if (dayOfYear == 3) cout << \"Wednesday\" << endl; else if (dayOfYear == 4) cout << \"Thursday\" << endl; else if (dayOfYear == 5) cout << \"Friday\" << endl; else if (dayOfYear == 6) cout << \"Saturday\" << endl; } cin.get(); cin.get(); return 0;

