You are on page 1of 1

SCHOOL OF SCIENCE & TECHNOLOGY

EEET2482 – SOFTWARE ENGINEERING DESIGN

ONLINE TUTORIAL WEEK 5

Task 1: Write a C++ program that takes in ten float numbers from the console. If the numbers are valid float
numbers, display them back to the console. Otherwise, send the invalid float numbers to the error stream.

• Invalid float numbers need to be detected and handled accordingly

• The cerr stream is to be redirected to a file instead of displaying the data to the console

Additional: Modify the code so the program takes in integer numbers from the console and verifies that the
numbers are valid integers.

Task 2: Write a C++ program that stores the following data into a binary file. The data from each array will be
stored into three binary files using different methods: a) insertion operator b) put method c) write method.

• Character array: 0x5A, 0x3F, 0x33, 0x3D, 0x40, 0x6B, 0x4C, 0x58, 0x72, 0x4E, 0x2F

• Integer array: 23, 36, 10, 00, 127, 256, 873, 365, 1024, 3425, 5096, 231, 943

• Double array: 34.25, 9e15, 3e-09, 935.23, -634.23, 345.92, -254.76, 8.9e5, 436.34e10

• Using a hex editor, analyse the data in each file and relate them to the above array data

Additional: Change the array of double values to type float correlate the data in the binary file to the data in
the new float array. What are the advantages and disadvantages of using each method?

Task 3: Write a C++ program that reads in data from the binary files created in the previous task and display
each value to the console using cout

• If possible, use all three methods to read in the data: a) extraction operator b) get method c) write
method

Additional: Use the stream formatting member functions to display each value to the console as a hexadecimal
and decimal number. The values displayed to the console should have appropriate precision and width, adjust
these parameters as required.

You might also like