Menu-driven program the will read an employee data and do the following?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Nora
il 27 Ott 2013
Commentato: Image Analyst
il 27 Ott 2013
I have a data set employee.dat
Name Department Birth_Date Date_Hired Salary Phone_Ext
'Smith, Jane' Service 072267 121298 87333 5188
'Smith, Joe' Sales 072269 121299 77333 5379
'Alkali, Sue' Account 010379 012202 57863 5256
'Mozart, Pat' Sales 033175 012201 65348 5378
'Kochab, Joe' Service 030172 121298 90132 5189
'Polaris, Curt' Account 091971 090102 90712 5255
'Dubhe, Mary' Sales 081370 090101 50365 5377
The program I am trying to make should read the information from the file into a data structure and then display a menu of options. The menu options are:
1. Print the information for all employees in a particular department (from user input).
2. Calculate the total payroll for the company (the sum of the salaries).
3. Find out how many employees have been with the company for N years (N might be 10,
for example).
4. Exit the program.
How do I obtain this?
0 Commenti
Risposta accettata
Walter Roberson
il 27 Ott 2013
See textscan(), and menu()
2 Commenti
Image Analyst
il 27 Ott 2013
Try this:
d = 121298 % Sample date
dstr = num2str(d)
month = str2double(dstr(1:2))
day = str2double(dstr(3:4))
year = str2double(dstr(5:end))
thisYear = str2double(datestr(now, 'YYYY'))-2000
if year > thisYear
year = 1900 + year
else
year = 2000 + year
end
serialDateHired = datenum(year, month, day)
serialDateNow = datenum(now)
daysElapsed = serialDateNow - serialDateHired
if daysElapsed > 365*3
msgbox('More than 3 years');
else
msgbox('Less than 3 years');
end
Of course you need to put in a few tweaks to handle leap years, but I assume you can figure that out.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Language Fundamentals in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!