Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Overig

COS2611 assignment 1 solution 2025

Beoordeling
3,3
(3)
Verkocht
23
Pagina's
12
Geüpload op
03-05-2025
Geschreven in
2024/2025

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.

Meer zien Lees minder
Instelling
Vak

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

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
3 mei 2025
Aantal pagina's
12
Geschreven in
2024/2025
Type
OVERIG
Persoon
Onbekend

Onderwerpen

€7,52
Krijg toegang tot het volledige document:
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

Beoordelingen van geverifieerde kopers

Alle 3 reviews worden weergegeven
10 maanden geleden

10 maanden geleden

10 maanden geleden

3,3

3 beoordelingen

5
0
4
1
3
2
2
0
1
0
Betrouwbare reviews op Stuvia

Alle beoordelingen zijn geschreven door echte Stuvia-gebruikers na geverifieerde aankopen.

Maak kennis met de verkoper

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 University of South Africa (Unisa)
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
486
Lid sinds
5 jaar
Aantal volgers
226
Documenten
73
Laatst verkocht
5 maanden geleden
CrystalIndigo Solutions

providing all solutions to all computer science modules

4,1

51 beoordelingen

5
27
4
13
3
6
2
1
1
4

Populaire documenten

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

Veelgestelde vragen