Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LinkedList.h header file containing your LinkedList template class. Destination.h [provided for you] Destination class TravelAgent.cpp contains the main function and any additional functions you created

LinkedList.h header file containing your LinkedList template class. Destination.h [provided for you] Destination class TravelAgent.cpp contains the main function and any additional functions you created to make the program run placeFile.txt [provided for you] feel free to add more destinations to this file Makefile [provided for you] if you name your files differently, then you will need to modify this file. batchFile.bat [provided for you] used to run the makefile and your program with the TEST_CASE.txt as input. TEST_CASE.txt [provided for you] sample input to test your program

TEST_CASE FILE:

Spongebob Squarepants f 10345 3 y 6 n

Description You are creating a program for a Travel Agent named Gavin O Cleirigh where you read in all your destination data from a text file (placeFile.txt) and then add each destination to a Linked List. The places should be in alphabetical order by place name in the nodes in the Linked List. Then, you will ask the user four different questions including name, salary, and then two other yeso questions of your choice. Then, you will generate a random number and get the Linked List node value at the position of this random number and tell the user that this is where they will be travelling. SPECIFICATIONS Linked List Template Class Create a template class named LinkedList, which will implement a singly linked list. (should be in LinkedList.h) private memebers Create a structure called ListNode, which should hold a template data type for the value and a pointer to the next ListNode ListNode pointer called head will eventually point to the first node in the linked list ListNode pointer called tail will eventually point to the last node in the linked list Integer called numNodes will hold the number of nodes in the linked list public members Constructor initialize head, tail, & numNodes Destructor deletes all nodes in the list getLength return the number of nodes currently in the linked list (returns numNodes) getNodeValue accepts an integer indicating the position in the linked list and will return the value in the node at that position (which is the template data type) insertNode this function is passed a node value (pointer to a Destination). Dynamically allocate a new node with the value sent to this function. If no nodes are in the list, insert the node as the head & tail. If the Destination name alphabetically goes after tails destination name, then insert this new node at the end of the linked list. Otherwise, you will traverse through the linked list to find the appropriate spot to insert the node so that the name is alphabetically in order. Travel Agent Program The program should be created in a source file named TravelAgent.cpp. Below is the logic of the main function. You may separate the logic in the main function into as many other programmer-defined functions as you want and name them whatever you want. However, your program must work as specified below: Create a linked list using the LinkedList template class. The template data type will be . Print out a welcome message like below. Hello! My name is Gavin O Cleirigh and I am your professional travel agent, tour director, and guide! Print out some ASCII Art that represents what Gavin may look like. In order to do this, I found a picture of a guy with his thumb up and then used this website (https://manytools.org/hacker-tools/convert-images-to-ascii-art/go/) to convert the image to ASCII. You can assume your code will be tested at an output width of 150 characters. Look at my sample output below. (I had to make the font tiny to make it fit on this page.) Enter in the text from the placeFile.txt file and after the data for each place is read in, dynamically allocate a new Destination object. Then, place the pointer to the Destination object in a new LinkedList node (call the insertNode function).

Next, print out all the destinations that are now in the Linked List. You can do this by having a for loop that will go from 0 to the number of nodes in the Linked List (call the getLength function) and then in the for loop you will call the getNodeValue function (sending the position of the node you want) and the function should return the value (which is a pointer to the Destination). Then, you can print out the Destination. Look at the sample output below. Below are all the possible travel destinations that I can hook you up with:

**********DESTINATION #1********** PLACE: Beckley, West Virginia DESCRIPTION: Beckley is a city in and the county seat of Raleigh County, West Virginia, United States. It was founded on April 4, 1838. Beckley was named in honor of John James Beckley, who was the first Clerk of the House of Representatives and the first Librarian of Congress. A notable site in the city is the Beckley Exhibition Coal Mine, a preserved coal mine that offers daily tours and a history lesson on coal mining in Appalachia. Sometimes there are reports of visitors seeing the monster called the Mothman. TRAVEL COST: $856.34 DANGER SCORE: 8

**********DESTINATION #2********** PLACE: Forest of Fangorn in Middle-Earth DESCRIPTION: Middle-earth is the main continent of Earth in a (supposedly imaginary) period of the Earth's past with the end of the Third Age about 6,000 years ago. The forest of Fangorn is the last remaining residence of Ents, who are tree-like creatures and are considered shepherds of the trees. TRAVEL COST: $543965 DANGER SCORE: 9

**********DESTINATION #3********** PLACE: Bikini Bottom DESCRIPTION: A square yellow sponge named SpongeBob SquarePants lives in a pineapple with his pet snail, Gary, in the city of Bikini Bottom on the floor of the Pacific Ocean. He works as a fry cook at the Krusty Krab. TRAVEL COST: $98.43 DANGER SCORE: 6

**********DESTINATION #4********** PLACE: Land of Oz DESCRIPTION: Oz is roughly rectangular in shape, and divided along the diagonals into four countries: Munchkin Country (but commonly referred to as 'Munchkinland' in adaptations) in the East, Winkie Country in the West (sometimes West and East are reversed on maps of Oz, see West and East below), Gillikin Country in the North, and Quadling Country in the South. In the center of Oz, where the diagonals cross, is the fabled Emerald City, capital of the land of Oz and seat to the monarch of Oz, Princess Ozma. Oz is completely surrounded on all four sides by a desert which insulates the citizens of the Land of Oz from discovery and invasion. Oz is mostly a peaceful land. TRAVEL COST: $12345.5 DANGER SCORE: 3

**********DESTINATION #5********** PLACE: Melmac (planet) DESCRIPTION: Melmac is a strange planet located in the Aldente Nebula in the Andromeda Galaxy. It is the homeworld of ALF. Residents of the planet were called Melmacians and they were characterized as being short, furry creatures who have remarkable longevity and multiple stomachs. Melmac is located six parsecs past the Hydra-Centaurus Supercluster. Melmac is very much like Earth but it has two moons, it is oddly shaped and made of melmac. Melmac has green skies and blue grass, and it orbits a purple sun. TRAVEL COST: $54394.5 DANGER SCORE: 2

**********DESTINATION #6********** PLACE: Narnia (world) DESCRIPTION: The mystical world of Narnia is a disc-shaped world (unlike Earth, which is spherical), with the sky like a great dome that meets the world around its circumference, on which the other side, and indeed all around the world's edges, is the mysterious land called Aslan's Country. The guardian and creator of the Narnian World, with the help of a few people, is the Great Lion, Aslan, himself who sent people (mostly children) from our own earth on missions to save Narnian society from destruction. TRAVEL COST: $0.75 DANGER SCORE: 7

**********DESTINATION #7********** PLACE: Strawberryland DESCRIPTION: Strawberryland is where Strawberry Shortcake lives with her calico cat Custard. Her house resembles a shortcake. Her friends are Huckleberry Pie, Blueberry Muffin, Raspberry Tart, Plum Puddin and toddler Apple Dumplin who also live close by. TRAVEL COST: $5643.87 DANGER SCORE: 1 Now you will ask the user four questions. This is to give the customer the false thought that you are actually choosing a destination based on something personal about them. The first question needs to be their name (including spaces). The second question needs to be their salary. If the user enters a letter instead of a number then force them to re-enter their data and make sure it is a positive number. The third and fourth questions can be whatever you want but they have to be yeso questions. Read in the users answer as a char (y or n). If the user did not enter a character or did not enter in a y or a n then force them to re-enter their data. You can validate the users data type to make sure it matches the variable you are reading into easily with !cin. Look at my program segment below to check if the user entered in a character. char response; cout > response; while(!cin) { cin.clear(); //removes all error flags on the stream

/* The ignore below will remove all leftover characters or numbers from keyboard buffer to start with fresh input. Also, you must #include to use numeric_limits */ cin.ignore(numeric_limits::max(), ); cout > response; } Sample Output 1 of User Input (when user enters in expected data types & values): ******************************************************************************** Please answer the following four questions and I will determine the place you should travel. 1. What is your full name? Kevin Malone 2. How much money do you make per year? 93842 3. Do you like the taste of fruity pebbles cereal? (y or n) y 4. Is planet Earth flat? (y or n) y Sample Output 2 of User Input when user enters wrong data types: ******************************************************************************** Please answer the following four questions and I will determine the place you should travel. 1. What is your full name? Spongebob Squarepants 2. How much money do you make per year? f

Oops! You entered something wonky. Please enter a number with no symbols or commas. 2. How much money do you make per year? 10345 3. Do you like the taste of fruity pebbles cereal? (y or n)? 3

Oops! You entered something wonky. Please enter the letter y or n. 3. Do you like the taste of fruity pebbles cereal? (y or n)? y 4. Is planet Earth flat? (y or n) 6

Oops! You entered something wonky. Please enter the letter y or n. 4. Is planet Earth flat? (y or n) n

Now, generate a random number between 0 and the number of nodes in the linked list (subtracting 1). You will then call the getNodeValue Linked List function to get the value of the node at this position number. Sample output is below. Spongebob Squarepants, based on your salary ($10345) and the fact that you like Fruity Pebbles cereal and you do not think that Earth is flat, you are going to travel to the following Destination! PLACE: Land of Oz DESCRIPTION: Oz is roughly rectangular in shape, and divided along the diagonals into four countries: Munchkin Country (but commonly referred to as 'Munchkinland' in adaptations) in the East, Winkie Country in the West (sometimes West and East are reversed on maps of Oz, see West and East below), Gillikin Country in the North, and Quadling Country in the South. In the center of Oz, where the diagonals cross, is the fabled Emerald City, capital of the land of Oz and seat to the monarch of Oz, Princess Ozma. Oz is completely surrounded on all four sides by a desert which insulates the citizens of the Land of Oz from discovery and invasion. Oz is mostly a peaceful land. TRAVEL COST: $12345.5 DANGER SCORE: 3

Last, print HAVE FUN!! HAVE FUN!!

image text in transcribed

image text in transcribed

Replace te and insert time object t Select all Editing or displayed improperly. 1 1. 2 Please answer the following four questions and I will determine the place you should travel. 1. What is your full name? Kevin Malone 2. How much money do you make per year? 93842 3. Do you like the taste of fruity pebbles cereal? (7 or n) 4. Is planet Earth flat? (y or n) Y Sample Output 2 of User Input when user enters wrong data types: Please answer the following four questions and I will determine the place you should travel. 1. What is your full name? Spongebob Squarepants 2. How much money do you make per year? f Dops! You entered something wonky. Please enter a number with no symbols or Comas 2. How much money do you make per year? 10345 3. Do you like the taste of fruity pebbles cereal? (7 or n) ? 3 Oops! You entered something wonky. Please enter the letter 1 or ne 3. Do you like the taste of fruity pebbles cereal? ty or n)? 4. Is planet Earth flat? (y or n) 6 Oops! You entered some thing wonky. Please enter the letter y or n. 4. Is planet Earth flat? (y or n) Now, generate a random number between 0 and the number of nodes in the linked list (subtracting 1). You will then call the getNodeValue Linked List function to get the value of the node at this position number. Sample output is below. Spongebob Squarepants, based on your salary ($10345) and the fact that you like Fruity Pebbles cereal and you do not think that Earth is nat, you are going to travel to the following Destination! PLACE: Land of Oz Oops! You entered something wonky. Please enter the letter y or n. 4. Is planet Earth flat? (y or n) n Now, generate a random number between 0 and the number of nodes in the linked list (subtracting 1). You will then call the getNodeValue Linked List function to get the value of the node at this position number. Sample output is below. Spongebob Squarepants, based on your salary ($10345) and the fact that you like Fruity Pebbles cereal and you do not think that Barth is flat, you are going to travel to the following Destination! PLACE: Land of Oz DESCRIPTION: Oz is roughly rectangular in shape, and divided along the diagonals into four countries: Munchkin Countri (but commonly referred to as 'Munchkinland in adaptations) in the East, Winkie Country in the West (sometimes West and East are reversed on maps of B2, see West and East below), Gillikin Country in the North, and Quadling Country in the South. In the center of Oz, where the diagonals Cross, is the fabled Emerald City, capital of the land of Oz and seat to the monarch of Oz, Princess Ozma. Oz is completely surrounded on all four sides by a desert which insulates the citizens of the land of Oz from discovery and invasion. Oz is mostly a peaceful land. TRAVEL COST: $12345.5 DANGER SCORE: 3 WI Last, print "HAVE FUN!!" Replace te and insert time object t Select all Editing or displayed improperly. 1 1. 2 Please answer the following four questions and I will determine the place you should travel. 1. What is your full name? Kevin Malone 2. How much money do you make per year? 93842 3. Do you like the taste of fruity pebbles cereal? (7 or n) 4. Is planet Earth flat? (y or n) Y Sample Output 2 of User Input when user enters wrong data types: Please answer the following four questions and I will determine the place you should travel. 1. What is your full name? Spongebob Squarepants 2. How much money do you make per year? f Dops! You entered something wonky. Please enter a number with no symbols or Comas 2. How much money do you make per year? 10345 3. Do you like the taste of fruity pebbles cereal? (7 or n) ? 3 Oops! You entered something wonky. Please enter the letter 1 or ne 3. Do you like the taste of fruity pebbles cereal? ty or n)? 4. Is planet Earth flat? (y or n) 6 Oops! You entered some thing wonky. Please enter the letter y or n. 4. Is planet Earth flat? (y or n) Now, generate a random number between 0 and the number of nodes in the linked list (subtracting 1). You will then call the getNodeValue Linked List function to get the value of the node at this position number. Sample output is below. Spongebob Squarepants, based on your salary ($10345) and the fact that you like Fruity Pebbles cereal and you do not think that Earth is nat, you are going to travel to the following Destination! PLACE: Land of Oz Oops! You entered something wonky. Please enter the letter y or n. 4. Is planet Earth flat? (y or n) n Now, generate a random number between 0 and the number of nodes in the linked list (subtracting 1). You will then call the getNodeValue Linked List function to get the value of the node at this position number. Sample output is below. Spongebob Squarepants, based on your salary ($10345) and the fact that you like Fruity Pebbles cereal and you do not think that Barth is flat, you are going to travel to the following Destination! PLACE: Land of Oz DESCRIPTION: Oz is roughly rectangular in shape, and divided along the diagonals into four countries: Munchkin Countri (but commonly referred to as 'Munchkinland in adaptations) in the East, Winkie Country in the West (sometimes West and East are reversed on maps of B2, see West and East below), Gillikin Country in the North, and Quadling Country in the South. In the center of Oz, where the diagonals Cross, is the fabled Emerald City, capital of the land of Oz and seat to the monarch of Oz, Princess Ozma. Oz is completely surrounded on all four sides by a desert which insulates the citizens of the land of Oz from discovery and invasion. Oz is mostly a peaceful land. TRAVEL COST: $12345.5 DANGER SCORE: 3 WI Last, print "HAVE FUN

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

Students also viewed these Databases questions

Question

Who are LOrals greatest competitors? Local, global, or both? Why?

Answered: 1 week ago