Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

COS2611 assignment 1 solution 2025

Rating
3.3
(3)
Sold
23
Pages
12
Uploaded on
03-05-2025
Written 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.

Show more Read less
Institution
Course

Content preview

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

Written for

Institution
Course

Document information

Uploaded on
May 3, 2025
Number of pages
12
Written in
2024/2025
Type
OTHER
Person
Unknown

Subjects

$8.59
Get access to the full document:
Purchased by 23 students

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Reviews from verified buyers

Showing all 3 reviews
10 months ago

10 months ago

10 months ago

3.3

3 reviews

5
0
4
1
3
2
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
CrystalIndigo University of South Africa (Unisa)
Follow You need to be logged in order to follow users or courses
Sold
486
Member since
5 year
Number of followers
226
Documents
73
Last sold
5 months ago
CrystalIndigo Solutions

providing all solutions to all computer science modules

4.1

51 reviews

5
27
4
13
3
6
2
1
1
4

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions