✔ C Sharp Code ⚡ Find avg per student from .csv file 🔥

using System;
using System.IO;
class Ex{
  public static void Main(string[]args){
    float avg;
    string line;
    string[]parts;
    using(StreamReader inf = new StreamReader("ex2.csv")){
      using(StreamWriter outf = new StreamWriter("ex2-out.csv")){
        while(null != (line = inf.ReadLine())){
          parts = line.Split(',');
          avg = ((int.Parse(parts[1])+int.Parse(parts[2])+int.Parse(parts[3]))/3.0f);
          outf.WriteLine("{0},{1:0.00}",parts[0],avg);
        }
      }
    }
  }
}
Download

Comments

Popular posts from this blog

Tecq Mate | Build APK with command line only | Build Android with cmd | No IDE | No Android Studio