100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Overig

COS2614 Assignment 1 2024 [DUE DATE : 17 May 2024] (CODE + LINK TO PROJECT)

Beoordeling
-
Verkocht
-
Pagina's
13
Geüpload op
15-05-2024
Geschreven in
2023/2024

Solutions to COS2614 Assignment 1. Code for both questions with a google drive link to download the complete project files for both questions. Guaranteed to get you 90% +. Please do not redistribute.

Instelling
Vak













Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
15 mei 2024
Aantal pagina's
13
Geschreven in
2023/2024
Type
Overig
Persoon
Onbekend

Onderwerpen

Voorbeeld van de inhoud

COS2614
Assignment 1
Semester 1 - 2024
Due Date: 17 May 2024




Disclaimer
These study notes are meant to aid your academic journey. They are not a substitute for
individual research or professional guidance, and their accuracy, while strived for, is not
guaranteed. You are responsible for verifying the information and maintaining academic
integrity by avoiding plagiarism and adhering to citation rules. The notes may not cover all
variations of a subject, so tailor your assignments to your specific academic environment.
The seller is not liable for any outcomes resulting from the use or misuse of these notes. By
using these notes, you agree to this disclaimer, which may be updated without notice.

,This document contains
1. Source code for both questions with screenshots

2. A Google drive link to download the project files





3. As a bonus you can download the prescribed textbook from the google
drive link






,Question 1 Preview:




Example:




1. Unique ID Generation: The program extracted the initials "NJ" from the first and last names,
"Nick" and "Johnson," respectively. It then counted the total number of characters in the full
name (excluding spaces), which was 16 characters. The count was padded with leading zeros
to make it 4 digits, resulting in "0016." Thus, the unique ID generated was "NJ0016."



2. Initial Key Generation: For the initial key, the program randomly selected 6 characters from
the full name "Nick Johnson." It ensured that at least one character was a vowel and one was
a consonant. The selected characters were "inhkis," resulting in the initial key "inhkis."



3. Output Display: The program displayed the generated unique ID ("NJ0016") and the initial
key ("ihnkisnoicnm") using a QMessageBox, providing a visual representation of the results
to the user.



4. User Interaction: The user interacted with the program by inputting their full name ("Nick
Johnson") through a QInputDialog. The program processed this input to generate the unique
ID and initial key, demonstrating the application's adherence to the specified rules for ID and
key generation.

,Question 2 Preview:




1. User Input: The program prompts the user to input the number of items (2) and details for
each item, including ID, name, and price. Additionally, it requests details for the vendor, such
as Vendor ID, Name, and Address.

,2. Item Initialization: Using the input data, the program initializes two StoreItem objects with
the specified IDs, names, and prices: "Laptop" (ID: 101, Price: $999.99) and "Smartphone"
(ID: 102, Price: $499.99).



3. Vendor Setup: The program creates a Vendor object with the provided details: Vendor ID:
201, Name: "ABC Electronics", Address: "123 Main Street."



4. Output Display: It then displays the details of each item, first without vendor information
and then with vendor details. Finally, it demonstrates the use of the getVendorName()
method to output the vendor name for each StoreItem.

, Question 1 Source code :




Main.cpp
#include <QApplication>
#include <QInputDialog>
#include <QMessageBox>
#include <QString>
#include <QStringList>
#include <cstdlib>
#include <ctime>

// Function to generate a unique ID based on the full name
QString generateUniqueID(const QString& fullName) {
// Split the full name into individual parts
QStringList nameParts = fullName.split(" ");
QString initials;
// Construct initials from the first characters of the name parts
if (nameParts.size() >= 2) {
initials += fullName.at(0).toUpper(); // First name initial
QString lastWord = nameParts.back();
if (nameParts.size() > 2)
initials += nameParts[1].at(0).toUpper(); // Middle name
initial
else
initials += lastWord.at(0).toUpper(); // Last name initial if
no middle name
}

// Remove spaces from the full name and count the number of
characters
QString nameWithoutSpaces = fullName;
nameWithoutSpaces.replace(" ", "");
QString countString = QString::number(nameWithoutSpaces.length());
// Pad the count with leading zeros to make it 4 digits
countString = countString.rightJustified(4, '0');

// Combine initials and count to form the unique ID
return initials + countString;
}

// Function to generate an initial key based on the full name
QString generateInitialKey(const QString& fullName) {
QString key;
// Remove spaces from the full name and convert to lowercase
QString nameWithoutSpaces = fullName;
nameWithoutSpaces.replace(" ", "");
QString name = nameWithoutSpaces.toLower();

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.
UnisaGuides University of South Africa (Unisa)
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
3793
Lid sinds
5 jaar
Aantal volgers
1642
Documenten
98
Laatst verkocht
1 maand geleden
Unisa Guides

_"Your Path to Academic Excellence"_ UnisaGuides, a trusted seller on the Stuvia platform, is dedicated to providing the University of South Africa (Unisa) students with the best study material and assignment help. With our extensive collection of study guides, textbooks, and expertly crafted assignments, we aim to support students in excelling in their studies. As a seller on Stuvia, we understand the importance of reliable and high-quality resources for students. Our study materials are carefully curated and created by experienced educators and subject matter experts who are familiar with the Unisa curriculum and requirements. We strive to ensure that our documents meet the needs of Unisa students, providing them with valuable insights and guidance. With user-friendly navigation and secure transactions, Stuvia makes it convenient for students to browse, purchase, and access our study materials. We are committed to delivering exceptional customer service and promptly addressing any inquiries or concerns. At UnisaGuides, our mission is to empower Unisa students to reach their academic potential. We invite you to explore our offerings on the Stuvia platform and discover the resources that can help you excel in your studies. Join the UnisaGuides community on Stuvia and unlock your path to success at Unisa.

Lees meer Lees minder
3,7

260 beoordelingen

5
119
4
41
3
46
2
15
1
39

Recent door jou bekeken

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