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

COS Assignment 2 solutions ready to submit, with source code

Rating
-
Sold
2
Pages
15
Uploaded on
05-06-2023
Written in
2022/2023

the document has the solutions to the second assignment

Institution
Course

Content preview

COS1512 2023 ASSIGNMENT 2
DISCUSSION
(with the source code you need)

Crystal Indigo!
Crystal Indigo!
Providing all solutions you need anytime
+27 76 626 8187




***copy and run the code, then submit what you need to submit***
Or ask for the source code
if there is a program that is not running, please contact

,Question 1
#include <iostream>
using namespace std;

// Function to calculate tuition fees for a student without repeated modules
double calcFees(int numModules, double moduleFee)
{
return numModules * moduleFee;
}

// Function to calculate tuition fees for a student with repeated modules
double calcFees(int numModules, double moduleFee, int numRepeatedModules,
double repeatedModuleFee)
{
return (numModules * moduleFee) + (numRepeatedModules * repeatedModuleFee);
}

int main()
{
int numModules, numRepeatedModules;
double moduleFee, repeatedModuleFee;

cout << "Does the student repeat any modules? (1 for Yes, 0 for No): ";
int repeatModules;
cin >> repeatModules;

cout << "Enter the number of modules enrolled for the first time: ";
cin >> numModules;
cout << "Enter the fee for those modules: R";
cin >> moduleFee;

if (repeatModules)
{
cout << "Enter the number of modules repeated: ";
cin >> numRepeatedModules;
cout << "Enter the fee for the repeated modules: R";
cin >> repeatedModuleFee;

double totalFees = calcFees(numModules, moduleFee, numRepeatedModules,
repeatedModuleFee);
cout << "Total tuition fees: R" << totalFees << endl;
}
else
{
double totalFees = calcFees(numModules, moduleFee);
cout << "Total tuition fees: R" << totalFees << endl;
}

return 0;
}

, Output




Question 2
#include <iostream>
#include <cassert>

using namespace std;

void convertTo12Hour(int hour24, int minute)
{
assert(hour24 >= 0 && hour24 < 24 && minute >= 0 && minute < 60);

string meridiem = (hour24 < 12) ? "AM" : "PM";
int hour12 = (hour24 == 0 || hour24 == 12) ? 12 : hour24 % 12;

cout << "12-hour notation: " << hour12 << ":" << minute << " " << meridiem
<< std::endl;
}

int main()
{
int hour24, minute;

cout << "Enter time in 24-hour notation (hour minute): ";
cin >> hour24 >> minute;

convertTo12Hour(hour24, minute);

return 0;
}

Written for

Institution
Course

Document information

Uploaded on
June 5, 2023
Number of pages
15
Written in
2022/2023
Type
OTHER
Person
Unknown

Subjects

$5.11
Get access to the full document:

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

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
6 year
Number of followers
226
Documents
73
Last sold
8 months ago
CrystalIndigo Solutions

providing all solutions to all computer science modules

4.1

52 reviews

5
27
4
13
3
6
2
1
1
5

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

Working on your references?

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

Working on your references?

Frequently asked questions