100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 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











Whoops! We can’t load your doc right now. Try again or contact support.

Document information

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

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;
}

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)
View profile
Follow You need to be logged in order to follow users or courses
Sold
486
Member since
5 year
Number of followers
226
Documents
73
Last sold
2 months ago
CrystalIndigo Solutions

providing all solutions to all computer science modules

4,1

51 reviews

5
27
4
13
3
6
2
1
1
4

Recently viewed by you

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

Frequently asked questions