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

CAN YOU HELP ME WITH THIS PLEASE IT IS AN EMERGENCY!!! I WANT TO WRITE THE FOLLO

ID: 3825302 • Letter: C

Question

CAN YOU HELP ME WITH THIS PLEASE IT IS AN EMERGENCY!!!

I WANT TO WRITE THE FOLLOWING PROGRAM IN C# CONSOLE BY LOADING ARRAYS FROM THIS FILE. THE ARRAYS ARE LOAD STARTING FROM THE SECOND LINE AND SO ON;

C# CONSOLE PLEASE!!

QUESTION

Find & Display All Students with a particular grade and display all the names.

              The user should input a grade.

Use a Linear Search that you code for this Search

             When you have a successful search (match), display that students name and continue to search for next person with that grade until you find and display all of those student names with the same grade, from input

Little Record2 Notepad File Edit Format View Help 20,00 Ann,5 DONNA, 24 REX,377 SUSAN,63 JOHNNY,0 KALEB, 69 CAROL, 66 TONY,11 FRANK ,4 BOBBI,0 Henry ,87 Bob, 77 Diane, 87 Paula ,90 George, 94 Larry,89 Sarah 77 Maggie,99 Pat, 54 Howard,87 Type here to search 00 PM 4/21/2017 L

Explanation / Answer

Hi I have created program that loads text from file "MyTest.txt" and displays name of the student.

Grades will be as follows:

"A: Marks above 70"
"B: Marks between 60-69"
"C: Marks between 40-59"
"D: Marks below 39"   

Text file contain following records:

20,0
Ann,5
DONNA,24
REX,377
SUSAN,63
JOHNNY,0
KALEB,69
CAROL,66
TONY,11
FRANK,4
BOBBI,0
Henry,87
Bob,77
Diane,87
Paula,90
George,94
Larry,89
Sarah,77
Maggie,99
Pat,54
Howard,87

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

namespace GradeFinder
{
class Program
{
static void Main(string[] args)
{
try
{
// Open the file to read from.
char grade;
string path = @"MyTest.txt";
Console.WriteLine("Grade:-");
Console.WriteLine("A: Marks above 70");
Console.WriteLine("B: Marks between 60-69");
Console.WriteLine("C: Marks between 40-59");
Console.WriteLine("D: Marks below 39");
Console.WriteLine("Grade:-");
Console.WriteLine("Enter grade:-");
grade = Console.ReadKey().KeyChar;
Console.WriteLine(" Student Names with Grade {0}", grade);
if (File.Exists(path))
{
string[] readText = File.ReadAllLines(path);
for (int i = 1; i < readText.Length; i++)
{
int marks;
string Name;
char currGrade;
Program.GetNameAndMarks(readText[i], out Name, out marks);
currGrade = FindGrade(marks);
if (currGrade == grade)
{
Console.WriteLine(Name);
}
}
}
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
}
}

public static void GetNameAndMarks(string line, out string name, out int marks)
{
int iIndex = line.IndexOf(",");
name = line.Substring(0, iIndex);
string temp = line.Substring(iIndex + 1);
marks = Int32.Parse(temp);
}

public static char FindGrade(int marks)
{
if (marks > 70)
return 'A';

if (marks > 60 && marks < 69)
return 'B';

if (marks > 40 && marks < 59)
return 'C';

if (marks < 39)
return 'D';

return 'Z';
}
}
}

Output:-

Grade:-
A: Marks above 70
B: Marks between 60-69
C: Marks between 40-59
D: Marks below 39
Grade:-
Enter grade:-
A
Student Names with Grade A
REX
Henry
Bob
Diane
Paula
George
Larry
Sarah
Maggie
Howard
Press any key to continue . . .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote