• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 12 pages
Other

COS2611 assignment 1 solution 2025

Document preview thumbnail
Preview 2 out of 12 pages

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.

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

Document information

Uploaded on
May 3, 2025
Number of pages
12
Written in
2024/2025
Type
Other
Person
Unknown
R143,33
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

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
4,1
(53)
Sold
491
Followers
226
Items
73
Last sold
1 month ago

Reviews from verified buyers




Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

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

Student with book image

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

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions