• Verkeerd document? Gratis ruilen
  • Geschreven door studenten die geslaagd zijn
  • Direct beschikbaar na je betaling
  • Online lezen of als PDF
Verkopen
Kies je studieland
Kies je taal
Document preview thumbnail
Voorbeeld 2 van de 12 pagina's
Overig

COS2611 assignment 1 solution 2025

Document preview thumbnail
Voorbeeld 2 van de 12 pagina's

COS2611 assignment 1 solution 2025 Using C++ and the linear data structures of queues and stacks, this project simulates a queue-based minibus taxi rank system—a common public transport method across Africa. The simulation will involve three types of taxis: Short-distance (S) Long-distance (L) City routes (C) Passengers arrive at the taxi rank and queue according to their destination. When a taxi becomes available, they board in an orderly manner based on their position in the queue. Each passenger requires some processing time to complete the onboarding process, which includes boarding the taxi and settling in. To test your implementation, download the taxiD file, which contains passenger arrival data. Note that a different dataset will be used during marking. Your implementation must incorporate linear data structures, specifically queues and stacks, to efficiently manage passenger boarding and taxi departures. Important: The data file is located at: Windows: C:datataxiD Mac/Linux: Update the path accordingly to match your system’s file structure. However, for the purpose of marking, the path must be in the format as for Windows, suggestion add a try-catch to prevent the program from crashing. Data Format Each row in taxiD represents a time instance at the taxi rank and contains three comma-separated values: timecount, route (S or L or C), boarding_time Example: 1,S,3 At time instance 1, a passenger arrives for the Short-distance (S) taxi. If no one is currently boarding, the passenger takes 3 time units to board. If another passenger is already boarding, they must wait until the taxi is available. Assumptions: All taxis have a capacity of five (5) passengers. A taxi will leave when full. Components Passenger Structure Each passenger is represented as a structure containing: Destination Type: Short-distance, Long-distance, or City route. Processing Time: Time taken for the passenger to board and for the taxi to fill up. Queue and Time Simulation Three separate queues represent the different taxi routes. The simulation runs for a specified duration. At each time step: A passenger may arrive and is assigned a queue based on their route. If a taxi is available for that route, the next passenger boards. The taxi departs once full. Output Format The simulation output should be displayed in a tabular format where: Each row represents a time step. Column Next displays the new passengers. Columns S, L anc C display the number of passengers in each queue. Columns waiting Q S, waiting Q L, waiting Q C display the passengers in the waiting queue that has to wait for the passenger infront of him/her. Columns Taxi Capacity for S, L and C indicating the current capacity for the taxis.

Voorbeeld van de inhoud

COS2611 ASSIGNMENT 1 2025
SOLUTION




NOTE: THIS WAS ATTEMPTED LAST MINUTE DUE TO NOT HAVING ACCESS TO THE
QUESTIONS EARLIER, HENCE NOT THAT PERFECT. NEXT TIME, ONCE ONE OF YOU
HAS THE QUESTIONS AND NEEDS HELP, PLEASE SEND THEM EARLY.

, OUTPUT




Source code, just copy and paste
#include <iostream>
#include <fstream>
#include <queue>
#include <string>
#include <sstream>
#include <iomanip>
#include <bits/stdc++.h>


using namespace std;


// Structure to represent a passenger
struct Passenger {
char destinationType; // 'S', 'L', or 'C'
int boardingTime; // Time needed to board
int arrivalTime; // Time when passenger arrived
int remainingTime; // Remaining boarding time
int id; // Passenger ID (for tracking)


Passenger(char type, int time, int arrival, int id) :
destinationType(type), boardingTime(time), arrivalTime(arrival),


remainingTime(time), id(id) {}
};


// Structure to represent a taxi
struct Taxi {
int capacity; // Maximum capacity
int currentPassengers; // Current number of passengers

Documentinformatie

Geüpload op
3 mei 2025
Aantal pagina's
12
Geschreven in
2024/2025
Type
Overig
Persoon
Onbekend
$8.95
Gekocht door 23 studenten

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
CrystalIndigo
4.1
(53)
Verkocht
491
Volgers
226
Items
73
Laatst verkocht
1 maand geleden

Reviews van geverifieerde kopers




Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen