Question
CAN YOU PLEASE CHECK MY SOLUTION BELOW? IT DOES NOT RUN function daysTill = birthdayFunction(month, day) %Take two numbers, month and day, and return the
CAN YOU PLEASE CHECK MY SOLUTION BELOW? IT DOES NOT RUN
function daysTill = birthdayFunction(month, day)
%Take two numbers, month and day, and return the number of days since jan 1
monthLength = [31, 28, 31, 30, 31, 30,31, 31, 30, 31, 30, 31];
%Get current date
t = clock;
%Get total days frp, Jan 1st to current date
daysElapsed = 0;
for i = 1:1:t(2)-1
daysElapsed = monthLength(i) + daysElapsed;
end
daysElapsed = daysElapsed + t(3);
%Get total days from Jan 1st to the Bday
daysTillBDay = 0;
for i = 1:1:month-1
daysTillBDay = daysTillBDay + monthLength(i);
end
daysTillBDay = daysTillBDay + day;
%Do subtraction
daysTill = daysTillBDay - daysElapsed;
months = {'January';'February';'March';'April';'May';'June';'July';'August';'September';'October';'November';'December'};
[num, txt] = xlsread('Book1.csv');
txt = strtrim(txt);
Name{1} = input('Input employee first name: ','s');
for i = 1:length(txt)
if strcmp(Name{1},txt(i,1))
day = num(i,1);
for j = 1:length(mos)
if strcmp(txt(i,3),mos(j))
month = j;
end
end
end
end
*************************************************************************
THE QUESTION IS:
Write a program in MATLAB that processes a series of employees to determine the days until/since a given employees birthday as follows:
To populate the employees' data, read in a comma separated file containing First Name, Last Name, Birthday Month, Birthday Day, and Salary. Use the file uploaded in Loud Cloud as an example.
Build up an array of employee records (i.e., structures) where each record contains the employee's first name, last name, birthday (stored as an integer representing days from January 1st), and salary.
Create a function that takes two numbers (month and day) as input and returns a single number (days since January 1st). This function will be used to "translate" the birthday format from that of the input file to that required for the data structures.
Create an array containing 12 values in which each number represents the days in each month of the year (i.e., 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31).
Subtract 1 from the input month and iterate over the array, adding in the value until you have the days in (month-1) months.
Add to this the number of the birthday day.
Prompt the user to supply an employees first name. Using the result, search through the array of structures to find the requested employee. Display the number of days between the current date and the employees birthday. Note that this will be a negative number if the employees birthday has already passed.
THE TABLE DATA IS:
Donald | Trump | 6 | 14 | 400000 |
Mickey | Mouse | 11 | 18 | 10000 |
Ada | Lovelace | 12 | 10 | 5000 |
Justin | Bieber | 3 | 1 | 125000 |
Benjamin | Franklin | 1 | 17 | 15000 |
Angela | Merkel | 7 | 17 | 234400 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started