Make a program in c++ that determine what day(sunday-saturday) is that particular date you input. Example Input: July 18, 2017 , Output: Tuesday
#include<iostream>
using namespace std;
//function to get date and return weekday number [0-6]
int getWeekDay(int yy, int mm, int dd)
{
//formula to get weekday number
int rst =
dd
+ ((153 * (mm + 12 * ((14 - mm) / 12) - 3) + 2) / 5)
+ (365 * (yy + 4800 - ((14 - mm) / 12)))
+ ((yy + 4800 - ((14 - mm) / 12)) / 4)
- ((yy + 4800 - ((14 - mm) / 12)) / 100)
+ ((yy + 4800 - ((14 - mm) / 12)) / 400)
- 32045;
return (rst+1)%7 ;
}
string getMonth(String month){
switch(month) {
case 'January' :
return month = 1
break;
case 'Febuary' :
return month = 2
break;
case 'march' :
return month = 3
break;
case 'April' :
return month = 4
break;
case 'May' :
return month = 5
break;
case 'June' :
return month = 6
break;
case 'July' :
return month = 7
break;
case 'August' :
return month = 8
break;
case 'September' :
return month = 9
break;
case 'October' :
return month = 10
break;
case 'November' :
return month = 11
break;
case 'December' :
return month = 12
break;
default :
cout << "Invalid month" << endl;
}
}
//main program/code
int main()
{
//declaring array of weekdays`
const char *Names[] = {"Sunday","Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday"};
int day = 0;
String DATE;
cin>>DATE;
vector<string> sep = split(DATE, ' ');
char month = sep[0];
char Date = sep[1];
char year = sep[2];
while(std::getline(Date,token,',')){
Date = token
}
month= getMonth(month)
//calling function, storing weekday number in day
day= getWeekDay(year,month,Date);
//printing the weekday from given array
cout<<"Day : "<< day <<endl;
return 0;
}
Make a program in c++ that determine what day(sunday-saturday) is that particular date you input. Example...
Write a simple Python program to find the day for the given date. The procedure to find the day of the week is as follows: F = (K + (13 * m – 1) mod 5 + D + D mod 4 + C mod 4 – 2 * C ) mod 7 where, K : day of the month m : month number D : remainder when year divided by 100 C : quotient when year is divided...
using C programming
Date Write a program that reads a month and a day in that month and prints the date in format "month day". The input is two integers, one between 1 and 12 (inclusive) and one between 1 and 31 (inclusive) and the output is a single line in format "month day". For example, for input 2 10 the program will print "February 10th". The day will always have the ordinal indicator, e.g. 1st, 2nd, 3rd, 4th. Example...
C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...
Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...
General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You should create identifiers with sensible names; • You should make comments to describe your code segments where they are necessary for readers to understand what your code intends to achieve. • Logical structures and statements are properly used for specific purposes. Objectives This assignment requires you to write...
C++ Project Modify the Date Class: Standards Your program must start with comments giving your name and the name of the assignment. Your program must use good variable names. All input must have a good prompt so that the user knows what to enter. All output must clearly describe what is output. Using the date class, make the following modifications: Make the thanksgiving function you wrote for project 1 into a method of the Date class. It receive the current...
Need this program ASAP
C++ language
1b. Write the implementation file timeClock.cpp for the class TimeClock. Com pile the file, and save it in the Chap 13 folder of your Student Data Files. 1c. Write a C++ program named weeklyPay.cpp to test your class Timeclock Your program should ask the user how many hours the user worked each day of the week. An object should be created for each day of the week with the number of hours for each...
Write a C# program that prints a calendar for a given year. Call this program calendar. The program prompts the user for two inputs: 1) The year for which you are generating the calendar. 2) The day of the week that January first is on, you will use the following notation to set the day of the week: 0 Sunday 1 Monday 2 Tuesday 3 Wednesday 4 Thursday 5 Friday 6 Saturday Your program should...
Write a C# program that prints a calendar for a given year. Call this program calendar. This program needs to use Switch Case in order to call the methods and format to print each month. The program prompts the user for two inputs: 1) The year for which you are generating the calendar. 2) The day of the week that January first is on, you will use the following notation to set the day of the week: ...
Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public: static string weekDays[7]; void print() const; string nextDay() const; string prevDay() const; void addDay(int nDays); void setDay(string d); string getDay() const; dayType(); dayType(string d); private: string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...