logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Remember the slogan Squidward, people order our patties

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Description

Remember the slogan Squidward, people order our patties. For today’s training program squidward, Mr. Krabs decided to buy the state of the art ordering system, so now you can work the grill. This automated system still preserves the essence of squidward, because we all know how customer friendly squidward can be. The automated ordering system needs to be able to look up menu items quickly, using a hash table.

template   <class   t1 ,   class   t2 > class    hash Map

{

public:  hash Map ();

t2 & operator []( t1 ); private :

void    resize ( int);

int    hash Function ( std :: string );

 

struct    keyVal

{

t1  key; t2   value ;

};

 

static    const    int    MAX_COLLISIONS   =   5; int    filled Entries ;

 

std :: vector <   std :: list <keyVal >   >   table ;

};

 

Each member contains/performs the following

 

struct keyVal - maintains an entry in the hash table

std::vector< std::list<keyVal> > table - hash table, an array of linked lists (each linked list is sorted by keys), each linked list contains no more than MAX_COLLISIONS amount of elements

int filledEntries - keeps track of the amount of linked lists in table are full (have MAX_COLLISIONS

amount of nodes)

static const int  MAX_COLLISIONS - the max amount of nodes that can be stored in each linked list in the table vector

hashMap<t1, t2>::hashMap() - constructor that sets filledEntries =  0 and sets the table size

table.resize(5)

t2& hashMap<t1, t2>::operator[](t1 key) - implements the insert/find bracket operator (finds/in- serts a node with the parameter key), the steps you follow are:

1. If the load factor is 20% or more (load factor is filledEntires /  table.size()), then

resize(table.size())

2. int i = hashFunction(key) % table.size()

3. auto it = table[i].begin() sets an iterator to point to the first node of the appropriate linked list

4. If a node with a matching key is found, then return this node’s value field

5. If a node with a matching key is not found and the linked list is not maxed out (the amount of nodes is less than MAX_COLLISIONS), insert a new entry into the correct spot of the linked list to preserve the sorted order (do not actually sort the entire list, just insert the element into the correct sorted spot),; set this node’s value field with t2(), if this insert causes this linked list to be maxed out, increment the filledEntries by 1; then return this new node’s value field

6. If the key does not exist and the linked list is maxed out, increment i = (i + 1)  % table.size()

and then go to step 2

int hashMap<t1, t2>::hashFunction(std::string key) - returns an integer using the hash object, the function contains

std :: hash <std :: string >   result; return    result( key );

 

void hashMap<t1, t2>::resize(int amount) - resizes the table by the parameter amount, this re- quires a re-map, only re-map the elements whose value fields do not contain t2() (this could happen when in main, a few failed searches occur but an actual new entry was created)

 

Main

In main you need to declare the following struct

struct menu Type

{

menu Type ()   :   price (0),   quantity (0.0)

{}

 

menu Type ( double   p,   int   q)   :   price ( p),   quantity ( q)

{}

 

// operator    used   in   the    hash Map :: resize ( int)   function

// that   is   used   to    determine   if   a   node ’s   value   is   not

 

// an   empty    entry

bool    operator !=( const    menu Type &   m)

{

return    quantity   !=   m. quantity   &&   price   !=   m. price ;

}

 

int    quantity ; double    price ;

};

 

And using this struct, you define the following hashMap

hashMap <std :: string ,   menuType >   krustyKrab Menu ;

 

Your program in main would follow the following steps

1. Prompt the user for an input file and open an std::ifstream infile variable

2. Create a std::vector<std::string> itemNames to store the item names in the same order they were read in (this is so we all get the same output for code grade)

3. Read each line (each line contains an item name, its price, and its quantity) and insert the item name into the itemNames vector and insert the element into the krustyKrabMenu hash table (you map the item name to menuType object that contains the item’s price and quantity amount)

4. Output the menu (only output the elements that are in stock i.e. the quantity of the item is above 0)

5. Prompt the user with the comforting message "Are you going to order today, sir? "

6. If the item name read in is not found or it’s quantity is 0, then output the message "We serve  food  here,  sir"

and go back to step 5, otherwise go to the next step

7. Output "Great, excellent choice" and then output "How many? " and then read in a quantity amount

8. If the quantity of the item is less than the quantity read, output "Try again: " and re-read the quantity, if the quantity is valid, go to the next step

9. Output "Well  done,  took  you  long  enough"

10. Subtract the quantity entered from the quantity from the item and update a running cost

11. If no items are left, output "Looks  like  you  ordered  everything  on  the  menu,  you  know  what  that  means"

then go to step 13

12. Prompt the user using the message "Will this complete  your  order?  ", if an upper or lower case N is entered go to step 4, else go to the next step

13. Output "Your order comes out to $" and then the order amount, then finalize the program with another passive aggressive Squidward message "Have a great day...barnacle head"

 

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

714 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

522 Answers

Hire Me
expert
Husnain SaeedComputer science

983 Answers

Hire Me
expert
Atharva PatilComputer science

633 Answers

Hire Me
April
January
February
March
April
May
June
July
August
September
October
November
December
2025
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
SunMonTueWedThuFriSat
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30