Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien
logo-home
COS1512 Assignment 2 2024 | Due 12 July 2024 2,64 €   Ajouter au panier

Examen

COS1512 Assignment 2 2024 | Due 12 July 2024

 63 vues  5 achats
  • Cours
  • Établissement
  • Book

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, ...

[Montrer plus]

Aperçu 2 sur 11  pages

  • 24 juin 2024
  • 11
  • 2023/2024
  • Examen
  • Questions et réponses
avatar-seller
, PLEASE USE THIS DOCUMENT AS A GUIDE TO ANSWER YOUR ASSIGNMENT


Please note that the author of this document will not responsibility for any plagiarizing you
commit.

 Question 1

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.

PROGRAM
#include <iostream>
#include <iomanip>

using namespace std;

const double GLOBALMAIL_COST_ZONE_1_TO_3 = 108.0;
const double GLOBALMAIL_COST_ZONE_4_TO_6 = 130.0;
const double DHL_COST_PER_KG = 70.0;
const double VOLUME_WEIGHT_DIVISOR = 5000.0;

double calcPostage(double weight, int zone) {
if (zone >= 1 && zone <= 3) {
return weight * GLOBALMAIL_COST_ZONE_1_TO_3;
} else if (zone >= 4 && zone <= 6) {
return weight * GLOBALMAIL_COST_ZONE_4_TO_6;
} else {
cerr << "Invalid zone provided." << endl;
return 0.0;
}
}

Les avantages d'acheter des résumés chez Stuvia:

Qualité garantie par les avis des clients

Qualité garantie par les avis des clients

Les clients de Stuvia ont évalués plus de 700 000 résumés. C'est comme ça que vous savez que vous achetez les meilleurs documents.

L’achat facile et rapide

L’achat facile et rapide

Vous pouvez payer rapidement avec iDeal, carte de crédit ou Stuvia-crédit pour les résumés. Il n'y a pas d'adhésion nécessaire.

Focus sur l’essentiel

Focus sur l’essentiel

Vos camarades écrivent eux-mêmes les notes d’étude, c’est pourquoi les documents sont toujours fiables et à jour. Cela garantit que vous arrivez rapidement au coeur du matériel.

Foire aux questions

Qu'est-ce que j'obtiens en achetant ce document ?

Vous obtenez un PDF, disponible immédiatement après votre achat. Le document acheté est accessible à tout moment, n'importe où et indéfiniment via votre profil.

Garantie de remboursement : comment ça marche ?

Notre garantie de satisfaction garantit que vous trouverez toujours un document d'étude qui vous convient. Vous remplissez un formulaire et notre équipe du service client s'occupe du reste.

Auprès de qui est-ce que j'achète ce résumé ?

Stuvia est une place de marché. Alors, vous n'achetez donc pas ce document chez nous, mais auprès du vendeur Aimark94. Stuvia facilite les paiements au vendeur.

Est-ce que j'aurai un abonnement?

Non, vous n'achetez ce résumé que pour 2,64 €. Vous n'êtes lié à rien après votre achat.

Peut-on faire confiance à Stuvia ?

4.6 étoiles sur Google & Trustpilot (+1000 avis)

73243 résumés ont été vendus ces 30 derniers jours

Fondée en 2010, la référence pour acheter des résumés depuis déjà 14 ans

Commencez à vendre!
2,64 €  5x  vendu
  • (0)
  Ajouter