Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Choices number 2 and 3 are not working. Can anyone provide a solution? function WPS_Report() data = {}; while true choice = displayMenu(); switch choice

Choices number 2 and 3 are not working. Can anyone provide a solution? function WPS_Report() data = {}; while true choice = displayMenu(); switch choice case 1 data = addDetails(data); case 2 data = calculateSalaryDelay(data); case 3 printReport(data); case 4 break; otherwise fprintf('Invalid option. Please try again. '); end if choice == 4 break; end end end function choice = displayMenu() clc; fprintf('Welcome to Wage Protection System '); fprintf('1. Add Details '); fprintf('2. Salary Delay '); fprintf('3. Print Report '); fprintf('4. Exit '); choice = input('Enter your choice: '); end function data = addDetails(data) employeeId = input('Enter employee ID: '); name = input('Enter name: ', 's'); salary = input('Enter salary amount: '); if salary < 1000 fprintf('Salary amount is less than 1000. Please enter salary greater than 1000. '); return; end paymentDate = input('Enter payment date (DD-MM-YYYY): ', 's'); dateComponents = datevec(paymentDate, 'dd-mm-yyyy'); if any(dateComponents == 0) fprintf('Invalid date format. Please enter the date in the format DD-MM-YYYY. '); return; end data{end+1} = struct('employeeId', employeeId, 'name', name, 'salary', salary, 'paymentDate', paymentDate, 'salaryDelayed', ''); end function data = calculateSalaryDelay(data) currentDate = datetime('today'); for i = 1:length(data) paymentDate = datetime(data{i}.paymentDate, 'InputFormat', 'dd-MM-yyyy'); if currentDate - paymentDate <= 7 data{i}.salaryDelayed = 'False'; else data{i}.salaryDelayed = 'True'; end end end function printReport(data) currentDate = datetime('today', 'Format', 'dd-MM-yyyy'); fileId = fopen('CentralBank_WPS.csv', 'w'); fprintf(fileId, 'Employee Id,Name,Salary Amount,Payment Date,Salary Delayed '); for i = 1:length(data) fprintf(fileId, '%d,%s,%d,%s,%s ', data{i}.employeeId, data{i}.name, data{i}.salary, data{i}.paymentDate, data{i}.salaryDelayed); end fclose(fileId); fprintf('Report generated as "CentralBank_WPS.csv". '); end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions