Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Otro

COS2611 assignment 1 solution 2025

Puntuación
3.3
(3)
Vendido
23
Páginas
12
Subido en
03-05-2025
Escrito en
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.

Mostrar más Leer menos
Institución
Grado

Vista previa del contenido

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

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
3 de mayo de 2025
Número de páginas
12
Escrito en
2024/2025
Tipo
OTRO
Personaje
Desconocido

Temas

$8.59
Accede al documento completo:
Comprado por 23 estudiantes

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Reseñas de compradores verificados

Se muestran los 3 comentarios
10 meses hace

10 meses hace

10 meses hace

3.3

3 reseñas

5
0
4
1
3
2
2
0
1
0
Reseñas confiables sobre Stuvia

Todas las reseñas las realizan usuarios reales de Stuvia después de compras verificadas.

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
CrystalIndigo University of South Africa (Unisa)
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
486
Miembro desde
5 año
Número de seguidores
226
Documentos
73
Última venta
5 meses hace
CrystalIndigo Solutions

providing all solutions to all computer science modules

4.1

51 reseñas

5
27
4
13
3
6
2
1
1
4

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes