Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

!!!!!!!!! Dart Programming !!!!!!!!!!!!! Prompt th? us?r for th? nam? of th? inp

ID: 3741677 • Letter: #

Question

!!!!!!!!! Dart Programming !!!!!!!!!!!!!

Prompt th? us?r for th? nam? of th? input fil? which contains th? stud?nt grad?s.

D?fin? a class Stud?nt, insid? stud?nt id, scor?s for lab, outsid?Lab, quiz, ?xams, finalScor?s, totalPoints, and l?tt?rGrad?. All m?mb?r data must b? privat?.

Th? class must provid? a function to calculat? th? final l?tt?r grad?. Calc().

Stor? all Stud?nt obj?cts in array(or map, hashmap, any data structur?.

For ?ach qu?ry, th? us?r inputs A#, and your cod? should print all information (including his/h?r final l?tt?r grad?) of th? stud?nt with th? giv?n a#. Aft?r two qu?ri?s, your program print information of all stud?nts on th? scr??n.

input.txt file

a1785432   6 15   2 34 54

a2785432   8 13   3 24 34

a3785432 34 34   4 43 23

a4785432   4 23 24 39 25

a5785432   8 17   5 44 37

a6785432   7 18   7 22 23

a7785432   4 15   6 34 54

a8785432   4 23   4 58 67

a9785432   4 18   9 28 27

a0785432   9 10   5 20 20

!!!!!!!!! Dart Programming !!!!!!!!!!!!!

Explanation / Answer

import 'dart:io';

import 'dart:convert';

import 'dart:async';

void main() async

{

print('Enter File Name : ');

String name = stdin.readLineSync();

File file = new File(name);

List<String> lines = await new File(name).readAsLines();

for(var i in lines)

{

print(i);

Grade ob = new Grade(i);

ob.Calc();

ob.pri();

}

}

class Grade

{

String sId;

int lab_M;

int out_M;

int quiz;

int exams;

int final_M;

int totalPoints;

char letterGrades;

int error ;

Grade(String line)

{

List<String> det = line.split(' ');

int len = det.length;

if(len!=6)

{

print("Missing data for ${sId}");

error = 1;

}

else

{

sId = det[0];

lab_M = int.parse(det[1]);

out_M = int.parse(det[2]);

quiz = int.parse(det[3]);

exams = int.parse(det[4]);

final_M = int.parse(det[5]);

error = 0;

}

}

void Calc()

{

if(error == 0 )

{

totalPoints = lab_M + out_M + quiz + exams + final_M ;

double ratio =totalPoints /500.0*100;

if(ratio >=(90.0))

{

letterGrades = 'A';

}

else if(ratio >=(80.0) && ratio<(90.0))

{

letterGrades = 'B';

}

else if(ratio >=(70.0) && ratio<(80.0))

{

letterGrades = 'C';

}

else if(ratio >=(60) && ratio<(70.0))

{

letterGrades = 'D';

}

else if(ratio >=(50) && ratio<(60))

{

letterGrades = 'P';

}

else if(ratio <(50))

{

letterGrades = 'F';

}

}

}

void pri()

{

if(error == 0)

{

print(" ====================== The Final Grade for ${sId} is : ${letterGrades} ============== ");

}

}

}