Question
using matlab please The learning objectives of this problem are: 1. Documentation of a computer program 2. Become familiar structs and table data type 3.
using matlab please
The learning objectives of this problem are: 1. Documentation of a computer program 2. Become familiar structs and table data type 3. Obtain information from a user 4. Make strategic decisions how to implement and maintain a database
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.
code that we need to fill in:
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
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