0% found this document useful (0 votes)
7 views

Programming Lab 9: - File I/O

The document provides instructions for two programming tasks. The first task involves reading student exam score data from a file, calculating mean exam scores, and identifying the student with the highest overall score. The second task involves generating Rayleigh distribution data for food lifetimes between 0-150 hours to a file for plotting. Additional resources are provided to help complete the tasks and learn more about file input/output in C++.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Programming Lab 9: - File I/O

The document provides instructions for two programming tasks. The first task involves reading student exam score data from a file, calculating mean exam scores, and identifying the student with the highest overall score. The second task involves generating Rayleigh distribution data for food lifetimes between 0-150 hours to a file for plotting. Additional resources are provided to help complete the tasks and learn more about file input/output in C++.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Programming Lab 9 - File I/O

Task 1
Consider a file called student.txt containing the name and exam
scores of 20 students in a class (the contents of the file is given right).
Write a C++ program to perform the following tasks:
a) Read the data from the file into suitable vectors.
b) Output the mean score for each exam (sum vertically each score column).
c) Output the name of the student with the highest overall score (sum horizontally
applying the weights 30%, 30%, and 40% for each column respectively).

You can download the data from:


http://www1.gantep.edu.tr/~eee241/labs/student.txt
If you need help starting, then use the following example program as a template:
http://www1.gantep.edu.tr/~cpp/tutorials/basic/src/09prg04.cpp

student.txt
UGUR
KADIR
SEMIH
GOZDE
FIRAT
EDA
FULYA
GUL
EMRE
AHMET
ISMAIL
MELIKE
TANER
SEHER
ALI
EMIN
HAVVA
FERDA
MUKRIME
TUGBA

67
72
00
73
30
51
41
67
30
76
67
71
59
79
90
88
76
10
54
61

38
45
71
70
69
58
65
69
40
41
15
65
50
51
88
92
85
25
15
70

Task 2
The lifetime of a food is distributed according to the Rayleigh distribution:
(http://en.wikipedia.org/wiki/Rayleigh_distribution)

Where x is the lifetime in hours and is the most likely lifetime.


Write a C++ program that outputs to a file the values of x and f(x) for 0 x 150 hours with =25 hours.
Import your file into Excel (or other similar program) and display the data in the form of a plot.

In your own time


Study the notes and perform the exercises that can be found at
http://www1.gantep.edu.tr/~cpp/tutorialbasic.php?topic=9

55
60
45
61
35
67
73
70
84
67
59
61
58
65
72
78
80
50
12
66

You might also like