Car wash simulation with queues

This is a discussion on Car wash simulation with queues within the C++ Programming forums, part of the General Programming Boards category; Having difficulty with understanding how to code the rest of this program. Simulation Problem: You own a car wash business ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    9

    Car wash simulation with queues

    Having difficulty with understanding how to code the rest of this program. Simulation Problem:

    You own a car wash business and want to analyze customer service information. The car wash opens at 8:00am. Customers drive up to a ticket dispenser where they choose option 1 for a wash only or option 2 for a wash and wax. The customer receives a car wash ticket which has the time in hours and minutes and the option number (1 or 2). The customer drives through the car wash once it is open and not busy. The time for option 1 is 10 minutes; the time for option 2 is 14 minutes.

    suggested pseudocode:

    Build the customer queue

    Print heading

    While (customer queue is not empty)

    Get a customer item from the queue

    Determine the wash time

    Determine the start time for this customer car

    Determine the finish time for this customer car

    Determine the wait time for this customer car

    Print the information for this customer

    Calculate and print the average wait time

    Here's what i have so far

    Code:
    #include<iostream>
    #include "linkedQueue.h"
    #include<fstream>
    
    using namespace std;
    struct TicketInfo
    {
           int stampHour;
           int stampMinute;
           int WashOption;
           };
    
    
    int main()
    {
     ifstream FileIn;
     FileIn.open("lab7.dat");
     linkedQueueType<int> TicketQueue;
     TicketInfo Customer;
     
     TicketQueue.initializeQueue();
     while(!FileIn.eof())
     {
       FileIn >> Customer.stampHour;
       FileIn >> Customer.stampMinute;
       FileIn >> Customer.WashOption;
       TicketQueue.addQueue(Customer.stampHour);
       TicketQueue.addQueue(Customer.stampMinute);
       TicketQueue.addQueue(Customer.WashOption);
       
    }
     cout << "Customer #  " << "Ticket Time  " << "Option  " << "Wash Time  "<< 
     "Start Time  " << "Finish Time  " << "Wait Time\n";
     
     while(!TicketQueue.isEmptyQueue())
     {
    
    }
    
    system("pause");
    return 0;
    }
    so I have built the queue, but stuck as to how to get a customer item from the queue and determine the wash and start times. Ive been reading through my textbooks for any references but could not find any. The functions that i need are left as an exercise in the book so no help there lol. I know i need the while loop which is empty at the moment. If anyone could offer any tips or suggestions, it will be greatly appreciated

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Your queue needs to be based off of your customer list, e.g. your ticket info. You essentially need to make a linked list here of your customers here (your stuct), iterate through the list, then based on wash option you need to calculate stop time. The start time would be based on the last customer's stop time, if there is a wait. I think you need to refresh on Linked Lists.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. queues
    By ashrrey in forum C Programming
    Replies: 3
    Last Post: 11-21-2010, 07:58 AM
  2. How do you wash your electric kettle?
    By Mario F. in forum General Discussions
    Replies: 13
    Last Post: 11-07-2009, 10:12 AM
  3. queues
    By rebelfirst in forum C++ Programming
    Replies: 9
    Last Post: 12-02-2007, 05:33 AM
  4. help with queues
    By Raideen in forum C Programming
    Replies: 2
    Last Post: 07-24-2002, 11:56 PM
  5. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 10:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21