Session 2

Examen 2018-2019 - Session 2

Part A:test

Getting start code - Part B

Start code: examen_code.tar.gz

Download the start code, upack it and copy the top directory examen_code in a new directory, named examen_YourFamilyName, or examen_YourFamilyName1_YourFamilyName2 if you work in binome. You should develop your solutions in the new directory.

cd 
tar xzvf examen_code.tar.gz
cp -r examen_code examen_YourFamilyName
cd examen_YourFamilyName

Task 1: fourDigits

The given code in fourDigits.cxx is buggy. Correct the compilation warnings, errors and the program behavior.

Task 2: cylinder

This task is to develop a simple program which computes the mass of a cylinder with the dimensions defined by the user for three given material.

  • Assignment 1: Ask the user for a radius and a height of a cylinder.

  • Assignment 2: Check that the read values represent a real cylinder.

      radius > 0
      height > 0
    

    If these conditions are not both satisfied report it and abort the program.

  • Assignment 3: Compute and display the volume of the cylinder:

      volume = PI * radius * height
    
  • Assignment 4: Compute the mass of the cylinder for the defined materials and print the results:

      mass = volume * density
    

Task 3: notation

This task is to complete the given program notation.cxx which purpose is to compute the number of failing students who passed an exam.

A teacher has a collection of marks for his students and would like to know how many passed the test.

  • Assignment 1: Please write a function taking the integer value representing the mark as a parameter and returning true if the mark is failing and false otherwise.
    (The mark is failing if its value is between 0 and 9 included.)

  • Assignment 2: Loop over the marks vector and find the number of failing students. Use your function.

  • Assignment 3: Display the number of failing students in percentage of their total number.

Task 4: notary

This task is to complete the given program notary.cxx. The program uses a given class Sale. Note that a Makefile is provided to facilitate the program compilation.

A Notary keeps track of every sale of a house (or an appartment) he made over the years in a given area. As a new regulation has passed, he is now responsible for checking that the unitary prices (in euros per square meters) are not changing too wildly over this area.

In this exercise you will find the class Sale that describes

  • the year of a sale
  • the surface of the house or appartment that was sold (in square meters)
  • the price it was sold (in euros).

The main program contains the information about all the sales, which are filled in the form of the objects of the Sale type (class) in the vector sales.

Complete the program to get printed the lowest, highest and average unitary price.

Hint: average = (sum of all values) / (number of values)

Your Solution

Pack the code which you developed in a single tar file and send the tar file by e-mail to both teachers: ivana@ipno.in2p3.fr, lafage@ipno.in2p3.fr.

Before you leave the room, check with the teachers that they received your code.

cd 
tar czvf examen_YourFamilyName.tar.gz examen_YourFamilyName

Solution: