txt file

Need to figure out how to properly count how many students, courses and average of their scores from a txt file. If there is a repeating course it will only count as one. For example below, class 345 is repeated so it would mean only two courses are below.

text file:

Shana Soro 345 12.5
Jim Pam 345 2.5
Sun Day 245 13.5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <string>
#include<fstream>
using namespace std;


struct mycode
{
    string first_name;
    string last_name;
    string room_number;
    double average;
}

int main()
{
       mycode obj[30];
       double total_average = 0;

       myfile.open("Text.txt");

       total_average = average/3;
       cout << "Their average is: " << total_average;
       cout << "The number of courses " << courses;
      
       cout << "Please enter the last name of the student you want";
       cin >> last_name;

       cout << ""; // needs to print out the information on that student
       cout << ""; //their ID 
       cout << ""; //their course
       cout << ""; //their score
Last edited on
If it is confusing let me know
If you write an algorithm. I will help you write the program
Topic archived. No new replies allowed.