100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COS2614 Assignment 1 2024 $5.63   Add to cart

Other

COS2614 Assignment 1 2024

4 reviews
 272 views  40 purchases
  • Course
  • Institution
  • Book

Code solutions to 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. As a bonus you can download the prescribed textbook from the link.

Preview 5 out of 12  pages

  • May 13, 2024
  • 12
  • 2023/2024
  • Other
  • Unknown

4  reviews

review-writer-avatar

By: deniselouw7 • 6 months ago

review-writer-avatar

By: mphomothibedi • 6 months ago

review-writer-avatar

By: jeremylosper • 6 months ago

review-writer-avatar

By: ndinannyijusticemukwevho1 • 6 months ago

avatar-seller
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:




What this project does:

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 :

// Include necessary header files
#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();

// Select at least one vowel and one consonant from the name
QChar vowel = QChar::Null;
QChar consonant = QChar::Null;
for (int i = 0; i < name.length(); ++i) {
if (name[i].isLetter()) {
if (name[i] == 'a' || name[i] == 'e' || name[i] == 'i' ||
name[i] == 'o' || name[i] == 'u') {
if (vowel.isNull())
vowel = name[i];
} else {
if (consonant.isNull())

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller UnisaGuides. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $5.63. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

73918 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$5.63  40x  sold
  • (4)
  Add to cart