Question

Write a code for a ride tracking app for Large Resort parks. In your app users...

Write a code for a ride tracking app for Large Resort parks. In your app users are going to be able to track wait times for up to five attractions, find the shortest wait time, and find the average wait time. //-----------------------------Sample Program Behavior with five attractions entered--------------------- Welcome to Large Resort Parks! Please enter the attractions you plan to visit and their wait times Ride 1 info: Attraction Name: 80 ft drop Wait time (in minutes): 40 Enter another attraction (y/n): y Ride 2 info: Attraction Name: kawabanga Wait time (in minutes): 60 Enter another attraction (y/n): y Ride 3 info: Attraction Name: Bumpy Roads Wait time (in minutes): 15 Enter another attraction (y/n): y Ride 4 info: Attraction Name: Simply scary Wait time (in minutes): 20 Enter another attraction (y/n): y Ride 5 info: Attraction Name: Never ending terror Wait time (in minutes): 45 Enter another attraction (y/n): n ATTRACTION WAIT TIME ---------------------------------------- 80ft drop 40 Kawabanga 60 Bumpy Roads 15 Simply Scary 20 Never Ending Terror 45 The shortest wait time is for Bumpy Roads (15 minutes). Average wait time for all attractions is 36 minutes. Enjoy your day at Large resort Parks, the most exciting resort to be. Press any key to continue . . . //---------------------------------End Sample Program Behavior------------------------------------- Program Specs Information the user enters must be stored in parallel arrays – one for attraction names and one for wait times. Attractions will be stored as string data and wait times as integer data. You must code a user-controlled “do” loop that will allow the user to populate the arrays with attractions and the wait times at runtime. The loop should keep going while the user types ‘y’ for yes or until the user reaches the maximum of five attractions. Attraction names might contain spaces example “Kawabanga” use getline rather than cin. Wait times can be use the regular cin. The wait times have to be between 0 and 250 minutes. Include an input validation loop to make sure the user stays within this range. Sample behavior: Ride 1 info: Attraction name: 80ft drop Wait time (in minutes): 400 Wait times must be between 0 and 250 minutes. Please re-enter: After each data pair is entered, flush the input stream with cin.ignore to get ready for the next attraction. This can be accomplished by adding the following line of code at the bottom of your loop, right above the “}while…”: cin.ignore(100, '\n'); //ignores next 100 characters or up to the newline/enter key Once the user is finished entering attractions and wait times or they must enter the maximum number of five attractions, a separate loop (a ‘for’ loop is fine) must display a chart showing each attraction and how long its wait time is. In the sample output, the attraction must be aligned in a field showing a width of 30 characters while wait times are right aligned in a field width of 10 characters. While also displaying the attraction and time chart, your program must also determine which attraction has the shortest wait time and display the attraction name and wait time and calculate the average wait time for all attractions entered and display that average as a whole number End your program with an “Have a great trip” message. The Variables const int MAX_RIDES = 20; An array of type string to hold the attraction names, set to MAX_RIDES elements The array of type int to hold the wait times, set to MAX_RIDES elements int currentArrtractionIndex = 0; int indexOfShortestWaitTime = 0; char again = ‘n’; //for user-controlled do loop int totalWaitTime = 0; //accumulator variable for computing the average int avgWaitTime = 0;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// C++ program to input the amusement rides and their waiting time and find the shortest waiting timr ride and

// average waiting time for all rides

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

       const int MAX_RIDES = 20;

       int currentAttractionIndex = 0;

       int indexOfShortestWaitTime = 0;

       char again = 'n';//for user-controlled do loop

       int totalWaitTime = 0; //accumulator variable for computing the average

       int avgWaitTime = 0;

       string attraction_name[MAX_RIDES];

       int attraction_time[MAX_RIDES];

       cout<<"\n\t\tWelcome to Large Resort Parks!\nPlease enter the attractions you plan to visit and their wait times "<<endl;

       // loop to continues till the user wants or till maximum rides info have not been entered

       do

       {

             cout<<"\nRide "<<(currentAttractionIndex+1)<<" info : "<<endl;

             cout<<"Attraction Name: ";

             getline(cin,attraction_name[currentAttractionIndex]);

             attraction_name[currentAttractionIndex] = attraction_name[currentAttractionIndex].substr(0,attraction_name[currentAttractionIndex].length()-1); // remove '\n' from the end of string

             cout<<"Wait time (in minutes): ";

             cin>>attraction_time[currentAttractionIndex];

             // validate attraction time

             while(attraction_time[currentAttractionIndex] < 0 || attraction_time[currentAttractionIndex] > 250)

             {

                    cout<<"Wait times must be between 0 and 250 minutes.\nPlease re-enter:";

                    cin>>attraction_time[currentAttractionIndex];

             }

             cout<<"Enter another attraction (y/n):";

             cin>>again;

             currentAttractionIndex++;

             cin.ignore(100, '\n');

       }while((again == 'y') && (currentAttractionIndex < MAX_RIDES));

       cout<<"\n"<<left<<setw(30)<<"ATTRACTION"<<left<<setw(10)<<"WAIT TIME"<<endl;

       cout<<string(50,'-')<<endl;

       indexOfShortestWaitTime = 0;

       // loop to display the rides information and calculate the index of the ride with the shortest wait time

       // and calculate the total wait time for all rides

       for(int i=0;i<currentAttractionIndex;i++)

       {

              cout<<left<<setw(30)<<attraction_name[i]<<left<<setw(10)<<attraction_time[i]<<endl;

             if(attraction_time[i] < attraction_time[indexOfShortestWaitTime])

                    indexOfShortestWaitTime = i;

             totalWaitTime += attraction_time[i];

       }

       // calculate the average wait time

       avgWaitTime = totalWaitTime/currentAttractionIndex;

       // output the shortest wait time ride and average wait time

       cout<<"\nThe shortest wait time is for "<<attraction_name[indexOfShortestWaitTime]<<" ( "<<attraction_time[indexOfShortestWaitTime]<<" minutes)."<<endl;

       cout<<"Average wait time for all attractions is "<<avgWaitTime<<" minutes"<<endl;

       cout<<"\nEnjoy your day at Large resort Parks, the most exciting resort to be.";

       return 0;

}

//end of program

Output:

Add a comment
Know the answer?
Add Answer to:
Write a code for a ride tracking app for Large Resort parks. In your app users...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Write a C++ program that user is able to choose the function of their wanting from this menu : Users will be asked...

    C++ Write a C++ program that user is able to choose the function of their wanting from this menu : Users will be asked to enter the movies they like along with the Genre and one Actor/Actress per movie. the entering process should look like this: Note that if the user enters yes, the program should start entering the next movie with its properties. Available movies must be entered as follow: The program should enter as many available movies as...

  • Step 4: Add code that discards any extra entries at the propmt that asks if you...

    Step 4: Add code that discards any extra entries at the propmt that asks if you want to enter another score. Notes from professor: For Step 4, add a loop that will validate the response for the prompt question:       "Enter another test score? (y/n): " This loop must only accept the single letters of ‘y’ or ‘n’ (upper case is okay). I suggest that you put this loop inside the loop that already determines if the program should collect...

  • Have you ever noticed the bar code printed on envelopes? That code helps the USPS process...

    Have you ever noticed the bar code printed on envelopes? That code helps the USPS process the mail. The barcode is generated as specified below. In this assignment you are to write a JAVA program that will accept a 5 digit number from the user and then prints the appropriate symbols to the screen. Name your file ZipCode_yourInitials.java. The specifications for the code are PostalCodeAsignment.pdf. Using a do while loop allow the user to continue entering numbers as long as...

  • PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs...

    PLEASE USE VERY BASIC REGISTERS AND CODE TO DO THE FOLLOWING Objectives: -write assembly language programs to:             -define a recursive procedure/function and call it.             -use syscall operations to display integers and strings on the console window             -use syscall operations to read integers from the keyboard. Assignment Description: Implement a MIPS assembly language program that defines "main", and "function1" procedures. The function1 is recursive and should be defined as: function1(n) = (2*n)+9                      if n <= 5              =...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • Can you help me to write a Java code for this: The program must satisfy the...

    Can you help me to write a Java code for this: The program must satisfy the following requirements: The program should ask the user the following information The site names for 6 locations (into an array) The cash donation for 6 locations (into an array) The food donations in pounds for 6 locations (into an array) Is there another test they want to process, meaning do they want to run the program again? Based on the input, the program will...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • (Write or type in answers, except for problem #15, which should be entered as a small...

    (Write or type in answers, except for problem #15, which should be entered as a small program, tested, and submitted in Repl.it) 1. Write a Python statement to define a list named temps using the following elements, in order: 95, 100, 77, 54, 103, 82 2. a) What is the length of the list temps? b) What Python function can be used to obtain the length of the list? Use it in a statement to obtain the length of temps...

  • Please help. I need a very simple code. For a CS 1 class. Write a program...

    Please help. I need a very simple code. For a CS 1 class. Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "printall" - prints all student records (first name, last name, grade). "firstname name" - prints all students with...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT