Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB Write a program Dog Hotel to generate and maintain a database. The program must use a table data structure, and the elements of the

MATLAB

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: switch choice

case 'I' dogs=checkIn(dogs) % you need to write the subfunction checkIn

','s'));

end end

printInventory(dogs) 

% you need to write the subfunction checkIOut

% % % % % %

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: )

end

otherwise

go=false;

case 'O' dogName=input('Enter dog name: ','s'); [dogs,bill]=checkOut(dogs,dogName); % you need to write the subfunction checkIOut

% Insert code to display the amount owed

function dogsOut=checkIn(dogs) % This is basically the Constructor function for table named dogs that consists of array of struct % User should be prompted to provide the information % Fields in struct should be

% % % and when completed, form the table dogs 

Here you place your code to first create the array of structures

end

function [dogsOut,bill]=checkOut(dogs,dogName)

% Complete the code % Stay is $100 per day, but dog is pitbull % Once checked out - the record of the dog

dogsOut=dogs; % temporary code - delete bill=0; % temporary code - delete end

then twice daily rate that is checked out should be erased from table dogs

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

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

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions