100% tevredenheidsgarantie Direct beschikbaar na betaling Zowel online als in PDF Je zit nergens aan vast
logo-home
COS1512 Assignment 2 (COMPLETE ANSWERS) 2024 (199828) - DUE 12 July 2024 Course Introduction to Programming II (COS1512) Institution University Of South Africa (Unisa) Book An Introduction to Programming in C €2,37   In winkelwagen

Tentamen (uitwerkingen)

COS1512 Assignment 2 (COMPLETE ANSWERS) 2024 (199828) - DUE 12 July 2024 Course Introduction to Programming II (COS1512) Institution University Of South Africa (Unisa) Book An Introduction to Programming in C

2 beoordelingen
 44 keer bekeken  3 aankopen
  • Vak
  • Instelling
  • Boek

COS1512 Assignment 2 (COMPLETE ANSWERS) 2024 (199828) - DUE 12 July 2024 Course Introduction to Programming II (COS1512) Institution University Of South Africa (Unisa) Book An Introduction to Programming in C

Voorbeeld 3 van de 21  pagina's

  • 23 juni 2024
  • 21
  • 2023/2024
  • Tentamen (uitwerkingen)
  • Vragen en antwoorden

2  beoordelingen

review-writer-avatar

Door: dumebigiovanni53 • 2 maanden geleden

review-writer-avatar

Door: sabrinaerasmus • 2 maanden geleden

reply-writer-avatar

Door: Jennifer2024 • 2 maanden geleden

Thanks .Keep purchasing

avatar-seller
COS1512 Assignment
2 (COMPLETE
ANSWERS) 2024
(199828) - DUE 12 July
2024 ;100% TRUSTED
workings,
explanations and
solutions.




ADMIN
[COMPANY NAME]

,Question 1 Peter wants to send a box containing a painting to
London. The Post Office sends parcels to London via GlobalMail or
DHL. If GlobalMail is chosen, the cost is R108 per kg if the parcel
goes to zone 1 to 3 in London, and R130 per kg if the parcel goes to
zone 4 to 6. If DHL is chosen, the actual weight is compared to the
volumetric weight, and whichever is the higher weight, is used in
the calculation. The volumetric weight is calculated by the formula
(length * width * height) / 5000, where length, width and height is
the size of the box in cm. The cost per kg for DHL is R70. Write a
program that will calculate the price to be paid for sending a parcel
to London. The program must use two overloaded functions, each
named calcPostage. The user must be asked if he wants to use
GlobalMail or DHL. Define a char variable and ask the user to input
„d‟ for DHL or „g‟ for GlobalMail. If he chooses GlobalMail, the
zone must be requested. The program must validate that the zone is
between 1 and 6. If he chooses DHL, the length, width and height of
the box must be requested. The first function will receive two
parameters, one of type double representing the weight of the parcel,
and one of type int, representing the zone. The second function will
receive four parameters of type double, representing the actual
weight, and the length, width and height of the box in cms. The
second function will first determine whether the actual weight or the
volumetric weight is the highest, before calculating the cost. Both
functions will return the cost in a variable of type double. The main
function should then display the total cost. Define const variables
where applicable. 3

, Here's a C++ program that implements the described functionality
for calculating the cost of sending a parcel to London using either
GlobalMail or DHL:
cpp
Copy code
#include <iostream>
#include <cmath> // for ceil function

using namespace std;

// Constants for GlobalMail rates
const double GM_ZONE1_3_RATE = 108.0; // Rands per kg for
zones 1 to 3
const double GM_ZONE4_6_RATE = 130.0; // Rands per kg for
zones 4 to 6

// Constant for DHL rate
const double DHL_RATE_PER_KG = 70.0; // Rands per kg for
DHL

// Function prototypes
double calcPostage(double weight, int zone);
double calcPostage(double actualWeight, double length, double
width, double height);

int main() {
char choice;
double weight, length, width, height, cost;
int zone;

// Ask user for choice of mail service
cout << "Enter 'g' for GlobalMail or 'd' for DHL: ";

Voordelen van het kopen van samenvattingen bij Stuvia op een rij:

Verzekerd van kwaliteit door reviews

Verzekerd van kwaliteit door reviews

Stuvia-klanten hebben meer dan 700.000 samenvattingen beoordeeld. Zo weet je zeker dat je de beste documenten koopt!

Snel en makkelijk kopen

Snel en makkelijk kopen

Je betaalt supersnel en eenmalig met iDeal, creditcard of Stuvia-tegoed voor de samenvatting. Zonder lidmaatschap.

Focus op de essentie

Focus op de essentie

Samenvattingen worden geschreven voor en door anderen. Daarom zijn de samenvattingen altijd betrouwbaar en actueel. Zo kom je snel tot de kern!

Veelgestelde vragen

Wat krijg ik als ik dit document koop?

Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.

Tevredenheidsgarantie: hoe werkt dat?

Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.

Van wie koop ik deze samenvatting?

Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper Jennifer2024. Stuvia faciliteert de betaling aan de verkoper.

Zit ik meteen vast aan een abonnement?

Nee, je koopt alleen deze samenvatting voor €2,37. Je zit daarna nergens aan vast.

Is Stuvia te vertrouwen?

4,6 sterren op Google & Trustpilot (+1000 reviews)

Afgelopen 30 dagen zijn er 73091 samenvattingen verkocht

Opgericht in 2010, al 14 jaar dé plek om samenvattingen te kopen

Start met verkopen

Laatst bekeken door jou


€2,37  3x  verkocht
  • (2)
  Kopen