Could someone show how to do this in C#? I keep getting errors for mine and the other answers on here that are similar doesn't work. And please make sure it accepts user input.
C# Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StudentScoresAvg
{
//Student Class
class Student
{
private int[]
scores;
private String
fName;
private String
lName;
//Constructor
public
Student(String first, String last, int s1, int s2, int s3, int s4,
int s5)
{
fName
= first;
lName
= last;
//Storing
scores in array
scores
= new int[5];
scores[0]
= s1;
scores[1]
= s2;
scores[2]
= s3;
scores[3]
= s4;
scores[4]
= s5;
}
//Storing
individual score
public void
setScore(int value, int index)
{
scores[index]
= value;
}
//Storing
names
public void
setFName(String first)
{
fName
= first;
}
//Storing
names
public void
setLName(String last)
{
lName
= last;
}
//Return
score
public int
getScore(int index)
{
return
scores[index];
}
//Returning
names
public String
getFName()
{
return
fName;
}
public String
getLName()
{
return
lName;
}
//Method that
calculates average
public double
getAverage()
{
double
sum = 0, avg;
for
(int i = 0; i < 5; i++)
{
sum
+= scores[i];
}
avg = sum / 5.0;
return
avg;
}
//Method that
returns letter grade
public String
getLetterGrade(double avg)
{
if
(avg >= 90)
return
"A";
else
if (avg >= 80)
return
"B";
else
if (avg >= 70)
return
"C";
else
if (avg >= 60)
return
"D";
else
return
"F";
}
//Method that
returns the string
public String
printStudent()
{
String
st = "";
st
=
string.Format("{0,-15}{1,-15}{2,-8:0.00}{3,-8:0.00}{4,-8:0.00}{5,-8:0.00}{6,-8:0.00}{7,-8:0.00}{8,-10}",
fName, lName, scores[0], scores[1], scores[2], scores[3],
scores[4], getAverage(), getLetterGrade(getAverage()));
return
st;
}
}
class Program
{
//Main method
static void
Main(string[] args)
{
//Reading
Student info
String
fName, lName;
int[]
scores = new int[5];
double classAvg,
classSum=0;
Student[] students = new Student[10];
//Reading
data
for
(int i = 1; i <= 10; i++)
{
//Reading
names
Console.Write("\n\n
Enter Student First Name: ");
fName
= Console.ReadLine();
Console.Write("\n
Enter Student Last Name: ");
lName
= Console.ReadLine();
Console.WriteLine("\n Enter five scores: ");
//Reading
scores
for
(int j = 0; j < 5; j++)
{
scores[j]
= Convert.ToInt32(Console.ReadLine());
}
//Creating
object
students[i
- 1] = new Student(fName, lName, scores[0], scores[1], scores[2],
scores[3], scores[4]);
}
String[]
arg = { "First Name", "Last Name", "Test 1", "Test 2", "Test 3",
"Test 4", "Test 5", "Average", "Grade" };
String
st =
string.Format("{0,-15}{1,-15}{2,-8}{3,-8}{4,-8}{5,-8}{6,-8}{7,-8}{8,-10}",
arg);
//Printing
header
Console.WriteLine("\n\n"
+ st + "\n");
//Printing
Student info
for
(int i = 1; i <= 10; i++)
{
Console.WriteLine(students[i
- 1].printStudent());
classSum += students[i - 1].getAverage();
}
classAvg =
classSum / 10.0;
Console.WriteLine("\n\nClass Average: " + string.format({0, 8:00},
classAvg));
Console.ReadKey();
}
}
}
_________________________________________________________________________________________________
Sample Run with two students info:
Could someone show how to do this in C#? I keep getting errors for mine and...
this is a java course class. Please, I need full an accurate answer. Labeled steps of the solution that comply in addition to the question's parts {A and B}, also comply with: (Create another file to test the class and output to the screen, not an output file) please, DO NOT COPY others' solutions. I need a real worked answer that works when I try it on my computer. Thanks in advance. Write the definition of the class Tests such...
Write the definition of the class Tests such that an object of this class can store a student's first name, last name, five test scores, average test score, and grade. (Use an array to store the test scores.) Add constructors and methods to manipulate data stored in an object. Among other things, your class must contain methods to calculate test averages, return test averages, calculate grades, return grades, and modify individual test scores. The method toString must return test data...
Having a bit of trouble in my c++ class, was wondering if anyone can help.Write a program to calculate students' average test scores and their grades. You may assume the following input data:Johnson 85 83 77 91 76Aniston 80 90 95 93 48Cooper 78 81 11 90 73Gupta 92 83 30 68 87Blair 23 45 96 38 59Clark 60 85 45 39 67Kennedy 77 31 52 74 83Bronson 93 94 89 77 97Sunny 79 85 28 93 82Smith 85 72...
Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...
Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...
THIS IS FINAL COURSE ASSIGNMENT, PLEASE FOLLOW ALL REQUIREMENTS. Hello, please help write program in JAVA that reads students’ names followed by their test scores from "data.txt" file. The program should output "out.txt" file where each student’s name is followed by the test scores and the relevant grade, also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in an instance of class variable of type...
Input hello, I need help completing my assignment for java,Use the following test data for input and fill in missing code, and please screenshot output. 1, John Adam, 3, 93, 91, 100, Letter 2, Raymond Woo, 3, 65, 68, 63, Letter 3, Rick Smith, 3, 50, 58, 53, Letter 4, Ray Bartlett, 3, 62, 64, 69, Letter 5, Mary Russell, 3, 93, 90, 98, Letter 6, Andy Wong, 3, 89,88,84, Letter 7, Jay Russell, 3, 71,73,78, Letter 8, Jimmie Wong,...
I want to change this code and need help. I want the code to not use parallel arrays, but instead use one array of struct containing the data elements, String for first name, String for last name,Array of integers for five (5) test scores, Character for grade. If you have any idea help would be great. #include #include #include #include using namespace std; const int NUMBER_OF_ROWS = 10; //number of students const int NUMBER_OF_COLUMNS = 5; //number of scores void...
C++ program that reads students' names followed by their test scores (5 scores) from the given input file, students.txt. The program should output to a file, output.txt, each student's first name, last name, followed by the test scores and the relevant grade. All data should be separated by a single space. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, an array of testScores of type int...
USE C++ FOR THE CODE THAT CAN RUN IN VISUAL STUDIO 2019 (or a complier) Ignore the last paragraph on the bottom of the page! \ Write a program YourName-Assignments (replace Your Name with your actual name, no spaces) that reads from students' records (one student per line) in the following format: Last Name Tests Grade Assignments Grade and computes and outputs (to the console) the STUDENT STATISTICS in a table format one line per student: Student Name Total Points...