I have a project and i did some of them but other i didn't do it
can any one help me please
in calcualte the average, sort and randomly
1. The program acceps
input for one student name and the student’s GPA . Maximum number of students and GPAs that can be entered are 20.2. The program calculates the average GPA for all the students that were entered.3. The program shows all student names with their GPA’s in a listbox.4. The program groups the student names in goups depending on the required group size and shows the student names in a listbox.5. The program can select a student from the student list (array) randomly and displays the name.
6. BONUS: The program sorts all GPAs and shows the student names with the GPAs in a sorted list
and this is my code
Code:
namespace Final_Project
{
publicpartialclassformStudent:Form {
// Declare and Initialize
double[] gpas =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
string[]names = {
" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ",
" ", " ", " ", " ", " ", " "};
int counter = 0;
public formStudent() {
InitializeComponent();
}
privatevoid btnEnter_Click(object sender, EventArgs e) {
// This method is called when we click the btn Enter buttom.
// It will enter the student name & GPA.
// The maximum number of student & GPA that can be entered are 20.
// Declare and Initialize
double gpa;
string name = txtName.Text;
// convert
gpa = Convert.ToDouble(txtGPA.Text);
// Move gpa to array
// only if counter is lees than 21
if (counter < 20) {
gpas[counter] = gpa;
names[counter] = name;
counter++;
MessageBox.Show("The name was entered");
} else {
MessageBox.Show("You cannot enter more names");
}
}
privatevoid btnList_Click(object sender, EventArgs e) {
// This method is called when we click the btn List buttom.
// It will list the student name & GPA in the list box.
for (int i = 0; i < counter; i++) {
lbStudentGPA.Items.Add(names[i] + " " + gpas[i]);
}
}
}
}