Question: Write a program Dog Hotel to generate and maintain a database. The program must use a table data structure, and the elements of the table
Write a program Dog Hotel to generate and maintain a database. The program must use a table data structure, and the elements of the table should be an array of structures. An outline with the start of the code is shown below. You should complete the indicated sections or follow a different approach to achieve a similar outcome. One of the important aspect will be to solicit information from a user. You could simply display an instruction and obtain input, or you could make use of predefined GUI message dialogs of MATLAB (e.g. menu, questdlg, inputdlg, etc). Do NOT use an event driven GUI. Make sure to deal with any errors the user may cause when information is entered. The program should not break or terminate when an input error occurs.
function dogs=dogHotel ()
disp('Generate a table for storing dog hotel information')
dogs=[]; % % temporary code - delete if necessary
go=true;
while go
choice=upper(input('Press I for check in, O for check out and Q for quit: ','s'));
switch choice
case 'I'
dogs=checkIn(dogs)
case 'O'
dogName=input('Enter dog name: ','s');
[dogs,bill]=checkOut(dogs,dogName);
otherwise
go=false;
end
printInventory(dogs) % print inventory
end
end
function dogsOut=checkIn(dogs)
% Complete the code Constructor function for table that consists of array of struct dogs
% User should be prompted to provide the
% information
% Fields in struct should be
% i) name : should be string (e.g. Enter the dog name: )
% ii) breed : should be string (e.g. Enter the dog breed: )
% iii) age : numeric (e.g. Enter the dog age: )
% iv) special_food : 1 sentence description (e.g. Enter the dog special food: )
% v) days: numeric (e.g. Enter the number of days the dog will stay: )
% vi) mobil: string (e.g. Enter mobile number: )
dogsOut=dogs; % temporary code - delete
end
function [dogsOut,bill]=checkOut(dogs,dogName)
% Complete the code
% stay is $100 per day, but dog is pitbull then twice daily rate
% Once checked out - the record of the dog should be erased from array of struct
dogsOut=dogs; % temporary code - delete
bill=0; % temporary code - delete
end
function printInventory(dogs)
disp('The following dogs are staying in the hotel: ')
% Complete the code to display name, breed, age, special food, days in hotel,
% and mobil number
end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
