This program needs to be written using C please provide all

This program needs to be written using C#; please provide all control names used in the application.

You are to develop an application that reads student records from a sequential text file from a secondary storage device and process them. For each student there are 4 records stored in the student file: the first record contains the full first and last name of the student, the second record contains the exam 1 grade, the third record contains the exam 2 grade and the fourth record contains the exam 4 grade.

Your app is to read the 4 records corresponding to each student, compute the average score of the three exams and display one line in a listbox containing the full name of the student, the average score and the corresponding letter grade to that score. Your app is to process an unspecified number of student records until the end of the input file is reached. The input file is to be specified by the user when the program invokes the OpenFile Windows dialog and allows the user to either select an input file or type the name of it. You should use the students1.txt file as your testfile while you develop your app.

Solution

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
class Program
{
public static int pos=0;
static void Main(string[] args)
{
readFromFile(\"D:\\\\student.txt\");
addrecord();

}


class Student
{

private string stnumber;
private string stname;
private int recordsize;


public string stunumber
{ //stunumber property

set { stnumber = value; }
get { return stnumber; }



}
public string stuname
{ //stuname property

set { stname = value; }
get { return stname; }



}

public int size
{

get { return calsize(); }
}
private int calsize()
{
recordsize = 2 * 15 + 2 * 20;// max record size
return recordsize;
}
}


static void addrecord(){


Student stu=new Student();
String con = \"y\";
while (con != \"n\")
{

Console.Write(\"Enter student number:\");

stu.stunumber = Console.ReadLine();

Console.Write(\"Enter student name:\");

stu.stuname = Console.ReadLine();
pos+= 1; //update position
writeToFile(\"D:\\\\Student.txt\", stu, pos, stu.size);
Console.WriteLine(\"Continue?y/n:\");
con=Console.ReadLine();
}




}

static void writeToFile(string filename, Student obj, int pos, int size){

FileStream fout;

BinaryWriter bw;

//create a file stream object

fout = new FileStream(filename, FileMode.Append , FileAccess.Write);

//create a binary writer object
bw = new BinaryWriter(fout);

//set file position where to write data
fout.Position = pos * size;
//write data
bw.Write(obj.stunumber );
bw.Write(obj.stuname );
//close objects
bw.Close();
fout.Close();



}

static void readFromFile(string filename){


FileStream fn;
BinaryReader br;

Student stu=new Student();

int currentrecord=0;


//open file to read data

fn = new FileStream(filename, FileMode.Open , FileAccess.Read);


br = new BinaryReader(fn);

//read next record
int i;
for(i=1; i<=(int)(fn.Length)/stu.size;i++){

currentrecord += 1; //update currentrecord position

fn.Seek(currentrecord * stu.size, 0);

stu.stunumber = br.ReadString().ToString() ;
stu.stuname = br.ReadString().ToString() ;

Console.WriteLine(stu.stunumber +\"\\t\"+stu.stuname );



}



//update pos to the current position

pos = currentrecord;

//close objects
br.Close();
fn.Close();

}


}


}

This program needs to be written using C#; please provide all control names used in the application. You are to develop an application that reads student record
This program needs to be written using C#; please provide all control names used in the application. You are to develop an application that reads student record
This program needs to be written using C#; please provide all control names used in the application. You are to develop an application that reads student record

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site