728x90 AdSpace

Latest Article



File Read or Write Java & C++ Practice problem Assignment Question Case study





IO Operation File Read or Write Java & C++ Practice problem Assignment Question Case study  

 You will create a program to read student marks from an input file and generate a histogram showing the average marks for each student.  You will write the resulting histogram to a file call “histogram.txt”.
The input file is called “marks.txt”. The format of the input file is very simple. Each line is a (roll-number, marks) pair, with a space between the roll-number and the marks. A roll-number is always be between 0 and 4 inclusive. Meaning that there will be marks for no more than 5 students. Hint! Marks are always between 0 and 20 inclusive. The end of the file is reached when you read a line with just a 'q' on it. A sample input file can look like this.

0 5
1 4
1 6
2 7
0 6
q

For each student, your program will keep a running average of marks. After reading the whole file, your program should know the average marks for each roll-number. The formula for calculating a running average is:
(running_average * num_marks_seen + current_marks) / (num_marks_seen + 1)

You will now generate a histogram showing the average marks for each students and will write it to the output file. A sample histogram is shown below.
7                     *                     *                    
6          *          *                     *                    
5          *          *                     *          *         
4          *          *                     *          *         
3          *          *          *          *          *         
2          *          *          *          *          *         
1          *          *          *          *          *         
            0          1          2          3          4
Roll-numbers appear on the horizontal axis. Marks appear on the vertical axis. Oh and there will be no more than
A sample input file will be provided to you. If you don't have it, please ask for it. 

no image
  • Title : File Read or Write Java & C++ Practice problem Assignment Question Case study
  • Posted by :
  • Date : 04:16
  • Labels :






  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment