0% found this document useful (0 votes)
8 views6 pages

Mongu Trades Training Institute Management Board It Section Certificate in Computer Studies Term Two Assignment

The document contains programming assignments for a Diploma in Computer Studies, focusing on two main programs: one for calculating election results based on user input of candidates and their votes, and another for calculating electricity charges based on units consumed. Each program includes user prompts, calculations for percentages or charges, and displays the results. Additionally, there are references to external sources related to the assignments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

Mongu Trades Training Institute Management Board It Section Certificate in Computer Studies Term Two Assignment

The document contains programming assignments for a Diploma in Computer Studies, focusing on two main programs: one for calculating election results based on user input of candidates and their votes, and another for calculating electricity charges based on units consumed. Each program includes user prompts, calculations for percentages or charges, and displays the results. Additionally, there are references to external sources related to the assignments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

MONGU TRADES TRAINING INSTITUTE MANAGEMENT BOARD

IT SECTION

CERTIFICATE IN COMPUTER STUDIES

TERM TWO ASSIGNMENT

PROGRAM: DIPLOMA IN COMPUTER STUDIES

COURSE: PROGRAMMING

NAME: PRECIOUS LUBASI

EXAM NO: 831115

LECTURER: MR MBUMWAE
#include <iostream>

#include <vector>

#include <string>

Using namespace std;

Int main()

Vector<string> candidates(10);

Vector<int> votes(10);

Int total_votes = 0;

// Input candidate names and votes

For (int I = 0; I < 10; ++i)

Cout << “Enter the name of candidate “ << I + 1 << “:”;

Cin >> candidates[i];

Cout << “Enter the number of votes for “ << candidates[i] << “: “;

Cin >> votes[i];

Total_votes += votes[i];

// Calculate and display results

Cout << “\nElection Results:\n”;

For (int I = 0; I < 10; ++i)

{
Double percentage = (static_cast<double>(votes[i]) / total_votes) * 100; Cout <<
“Candidate: “ << candidates[i] << “, Votes: “ << votes[i] << “, Percentage: “ << percentage <<
“%\n”;

// Determine the winner

Int winner_index = 0;

For (int I = 1; I < 10; ++i)

If (votes[i] > votes[winner_index])

Winner_index = I;

Cout << “\nThe winner is “ << candidates[winner_index] << “ with “ << votes[winner_index]
<< “ votes.\n”;

Return 0;

This program will:

1. Prompt the user to enter the names and votes for 10 candidates.

2. Calculate the percentage of total votes each candidate received.

3. Display each candidate’s name, votes received, and percentage of total votes. 4.

Announce the winner based on the highest number of votes


#include <iostream>

using namespace std;

int main() {

//we can enter the number of 1000 customers, we start with 5 customers

const int numCustomers = 5; const double rate1 = 2.00; const

double rate2 = 3.50; const double rate3 = 4.50; const double gstRate

= 0.15;

for (int i = 1; i <= numCustomers; i++) { int

unitsConsumed; double

electricityCharges, gst, amountDue;

cout << "Enter units consumed for customer " << i<< ": ";

cin >> unitsConsumed;

if (unitsConsumed <= 100) {

electricityCharges = unitsConsumed * rate1;

} else if (unitsConsumed <= 200) { electricityCharges = 100 *

rate1 + (unitsConsumed - 100) * rate2;

} else {

electricityCharges = 100 * rate1 + 100 * rate2 + (unitsConsumed - 200) * rate3;

}
gst = electricityCharges * gstRate;

amountDue = electricityCharges + gst;

cout << "Electricity Charges: ZMK " << electricityCharges << endl;

cout << "General Sales Tax: ZMK " << gst << endl; cout <<

"Amount Due: ZMK " << amountDue << endl << endl;

return 0;

This program will:

1. Prompt the user to enter the units consumed.

2. Calculate the Electricity Charges (EC) based on the provided criteria.

3. Calculate the General Sales Tax (GST) as 15% of the EC.

4. Display the Electricity Charges, General Sales Tax, and Total Amount Due.

References
(1) . https://www.chegg.com/homework-help/questions-and-answers/1-good-
normallycosts-50-purchase-10-units-discounted-price-20-applies-upper-limit-total-q-
q123637048.

(2) . https://www.chegg.com/homework-help/questions-and-answers/manufacturer-
newproduct-claims-product-increase-output-per-machine-least-38-units-per-
houq43768444.

(3) https://www.chegg.com/homework-help/questions-and-answers/customer-
tableemployee-table.... https://www.chegg.com/homework-help/questions-
andanswers/customer-table-employee-table-supplier-table-product-returns-table-
producttable-sales-tab-q103576344.

(4) https://www.numerade.com/ask/question/a-company-produces-a-product-
anddelivers-to-its.... https://www.numerade.com/ask/question/a-company-produces-
aproduct-and-delivers-to-its-customers-for-orders-placed-online-value-of-the-product-
isrs-1000-and-a-delivery-fee-of-rs-300-per-product-is-charged-a-discount-of-3-was-
alsogiven-f/.

(5) https://github.com/googlecolab/colabtools/issues/16.
https://github.com/googlecolab/colabtools/issues/16.

You might also like