WRITE THE ALGORITHM PSEUDOCODE FOR EACH OF THE FOLLOWING(NO CODE JUST PSEUDOCODE)
1.DETERMINE THE DAY OF THE WEEK FOR ANY GIVEN DATE WITHIN THE SAME WEEK
(EX. TODAY IS 03/24 TUE, SO 03/23 MUST BE MON)
2. DETERMINE THE DAY OF THE WEEK FOR ANY GIVEN DATE WITHIN THE SAME MONTH
(EX. TODAY IS 03/24 TUE, SO 03/15 MUST BE SUN)
3. DETERMINE THE DAY OF THE WEEK FOR ANY GIVEN DATE WITHIN THE SAME NON LEAP YEAR
(DO NOT COPY OR USE THE TOMOHIKO SAKAMOTO OR DOOMSDAY ALGORITHMS)
Hello, please find the below detailed explanation for the asked question. And in case of any doubt please don't forget to ask your queries in the comment section.
===============================================
Solution 1:
For this firstly, create an array of string for 7 days i.e.
string arr[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
then calculate the sum,
sum = [array index of today + (asked date - today date)]
and then compute i = sum%7 and print the array arr[i].
-----------------------------------------------------------------------------
Example :
Today = 03/24 TUE
Asked = 03/23
Hence, sum = [2 + 23 - 24] = 1
i = 1%7 = 1
and arr[1] = "MON"
===============================================
Solution 2:
For this firstly, create an array of string for 7 days i.e.
string arr[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
then calculate the sum,
if asked date > today date then, sum = [array index of today + 7 + (asked date - today date)%7]
else, sum = [array index of today + 7 - (today date - asked date)%7]
and then compute i = sum%7 and print the array arr[i].
-------------------------------------------------------------------
Example :
Today = 03/24 TUE
Asked = 03/15
Since, Asked date < today date
Hence, sum = [2 + 7 - (24 - 15)%7] = 7
i = 7%7 = 0
and arr[1] = "SUN"
===============================================
Solution 3:
For this firstly, create an array of string for 7 days i.e.
string arr[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
Then, calculate the number of days between asked and today date. This will be equal to days.
now calculate days%7.
if(today date > asked date){
print arr[(array index of today + 7 - (days%7)) % 7]
}
else{
print arr[(array index of today + 7 + (days%7)) % 7]
}
===============================================
Hope, you will understand the explanation. In case of any query, please feel free to ask. And please don't forget to give a like to this explanation.
WRITE THE ALGORITHM PSEUDOCODE FOR EACH OF THE FOLLOWING(NO CODE JUST PSEUDOCODE) 1.DETERMINE THE DAY OF...
Program 5: Design (pseudocode) and implement (source code) a program (name it Weekl yHours) to compute the total weekly hours for 3 employees. The program main method defines a two-dimensional array of size 3x7 to store employers' daily hours for the week. Each row represents one employee and each column represent one day of the week such that column 0 designates Monday, column 1 designates Tuesday, etc. The program main method populates the array with random numbers between 0 and...
c++ please :)
First, ask the user to enter a year (4-digit) and what week day does this year starts with (String) For example, the year 2018 starts with the week day "Friday". In this case, the calendar should start from January 1 which is Friday, 2018 Your program should produce a formatted calendar for the specified year and there should be a blank line after each month. Moreover, the month and the year should be centered over each month....
IN PYTHON the original problem was Design (pseudocode) and implement (source code) a program (name it WeeklyHours) to compute the total weekly hours for 3 employees. The program main method defines a two-dimensional array of size 3x7 to store employers’ daily hours for the week. Each row represents one employee and each column represent one day of the week such that column 0 designates Monday, column 1 designates Tuesday, etc. The program main method populates the array with random numbers...
In Java You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program: /** Interface for Date objects to be used by the Year3000 driver program. @author Jon Sorenson */ public interface DateInterface { /** @return the day of the month (1-31) */ public int getDay(); /** @return the day of...
PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program that reads a values for hour and minute from the input test file timeData.txt . The data read for valid hour and valid minute entries. Assume you are working with a 24 hour time format. Your program should use functions called validateHour and validateMinutes. Below is a sample of the format to use for your output file timeValidation.txt : ...
Write a function to determine the day of the week a person was born given his or her birthday. The following steps should be used to find the day of the week corresponding to any date from 1901 through the present. In the following explanation, the following terms will be helpful. Assuming I type in my birthday as "6 10 1981": The month is 6. The day of the month is 10. The year is 1981. Find the number of...
Write pseudocode to solve the following problem: You are given an array A[1...n] whose each element is a point of the plane (x,y). You need to sort the array so that points with lower x-coordinates come earlier, but among points with the same x-coordinate, the ones with larger y-coordinate come earlier. So, for example, if the array contains: (1,2), (1,4), (7,10), (11,3), (14,1), (7,2) The output, in this case, should be: (1,4), (1,2), (7,10), (7,2), (11,3), (14,1) Analyze the running...
(a) (1 pointd What type of problem, hence model ls this? (b) [14 pointa] Formulate the LP for the problem 3. The management of a hospital is trying to find an optimal schedule for its 60 nurses. There are three shifts everyday: Night (24:00-8:00), Day (8:00-16:00) and Swing (16:00-24:00). Minimum number of nurses who must be on duty each shift is given below: [16 points) Shift Mon Tue Wed Thu Fri Sat Sun Night 5324 3 22 Day795 725 Swing...
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...
Lab/HW 3 Write a program that reads in the following data, all entered on one line with at least one space separating them: a) an integer representing a month b) an integer representing the day of the month c) an integer representing a year 1. Check that the month is between 1 and 12. If it’s not print an error message. 2. Day cannot be 0 or less nor can it be more than 31 for all months. Print...