100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4,6 TrustPilot
logo-home
Notas de lectura

COS1512 ASSIGNMENT 02 ANSWERS/SOLUTIONS 2024

Puntuación
-
Vendido
1
Páginas
17
Subido en
11-07-2024
Escrito en
2023/2024

The document above is a memo for COS1512 ASSIGNMENT 2 2024

Institución
Grado










Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
11 de julio de 2024
Número de páginas
17
Escrito en
2023/2024
Tipo
Notas de lectura
Profesor(es)
Ms portia buthelezi
Contiene
Todas las clases

Temas

Vista previa del contenido

COS1512/201/2/2018




Tutorial letter 201/2/2018
Introduction to Programming II


COS1512
School of Computing
This tutorial letter contains the
solutions to Assignment 1

, COS1512/201/2/2018

INTRODUCTION

By the time you receive this tutorial letter you should have already completed assignment 1 and we
hope that you are well on your way with your studies. This tutorial letter contains the solutions to
Assignment 1. You are welcome to e-mail me with any queries at . Also take
note of the following telephone number and the days on which the lecturer are available in case you
have to call.

Mondays Dr MA Schoeman 011 670 9178
Tuesdays Dr MA Schoeman 011 670 9178


Allocation of marks
When we mark assignments, we comment on your answers. Many students make the same mistakes
and consequently we discuss general problems in the tutorial letters. It is, therefore, important to work
through the tutorial letters and to make sure you understand our solutions and where you went wrong.
The maximum number of marks you could obtain for Assignment 1 is 40. This is converted to a
percentage. If you for instance obtained 28 marks for Assignment 1, you received 28/40 * 100 = 70%
for Assignment 1. This percentage in turn contributes a weight of 20% to the year mark, as can be
seen in the summary of the weights allocated to the assignments for COS1512 below.

Assignment
Weight
number
1 20
2 80
3 0

We give the mark allocation for the questions below. For questions 1 – 4 you will not get any marks if
you did not include the program code. Or if you only included part of the code, you will get a maximum
of 2 marks if the included code is correct. Please note that this is NOT the way exam answers will
be marked. In the exam you will receive marks for specific statements as indicated by the exam
question. The purpose of the assignments is to provide you with an opportunity to practice the
concepts you are studying. Your marks for the assignment is an indication of whether or not you could
implement those concepts. If you did not include the output for your program, you will not get full
marks for the question. We discuss a possible solution for each question below. Please read through
the solution and discussions thoroughly.

The marks you received for question 1 was determined on the following basis:
Question not done 0/10
Question attempted, but the program does not work at all 4/10
A good attempt, but there are a few problems with your answer 8/10
The program works correctly and produces the correct output 10/10

The marks you received for question 2 was determined on the following basis:
Question not done 0/5
Question attempted, but the program does not work at all 2/5
A good attempt, but there are a few problems with your answer 4/5
The program works correctly and produces the correct output 5/5

The marks you received for question 3 was determined on the following basis:
Question not done 0/15
Question attempted, but the program does not work at all 5/15
A good attempt, but there are a few problems with your answer 11/15
The program works correctly and produces the correct output 15/15


2

, COS1512/201/2/2018


The marks you received for question 4 was determined on the following basis:
This question was not marked. If you attempted the question, you will get 5 marks. If not, you will get 0
marks. Please go through the solution that we give for question 4 to make sure that you understand
how to work with text files.

The marks you received for question 5 was determined on the following basis:
This question was not marked. If you attempted all the questions, you will get 5 marks. If you have not
attempted both questions 5(m) and (n), you will get 2 marks. If you have not attempted one of
questions 5(m) or 5(n), you will get 3 marks. If you have not attempted the question at all, you will get
0 marks. Please go through the solution that we give for question 5 to make sure that you understand
how to work with pointers.


Solution to Assignment

Question 1 10 marks

For this question you had to write a program to use two overloaded functions, each named
calcPostage(), to determine the postage for a parcel 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.
Function overloading is the practice of declaring the same function with different signatures. This
means that the same function name will be used with a different number of parameters and/or
parameters of different types. But overloading of functions with different return types is not allowed. In
this question you had to write an overloaded function named calcPostage with either two
parameters (one of type double and one of type int), or four parameters of type double. Although it
was not specified in the question, our program only displays two digits after the decimal point.


Program listing
//Ass 1 question 1
#include <iostream>
using namespace std;
const double zone1to3 = 108.00;
const double zone4to6 = 130.00;
const double DHL = 70.00;
const double factor = 5000;

//overloaded function GlobalMail
//Pre: weight in kg and the zone
//Post: returned cost for sending the parcel
double calcPostage (double weight, int zone);

//overloaded function for DHL
//Pre: actual weight and length, width and height of parcel
//Post: returned cost for sending the parcel
double calcPostage (double weight, double length, double width, double
height);


int main()


3
$5.80
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
JayJo University of South Africa (Unisa)
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
51
Miembro desde
4 año
Número de seguidores
46
Documentos
24
Última venta
2 meses hace

4.0

4 reseñas

5
3
4
0
3
0
2
0
1
1

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes