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

In C# Using a Windows form application. Your application must also make use of a

ID: 3679893 • Letter: I

Question

In C# Using a Windows form application.

Your application must also make use of a custom method and utilize arrays.

You should modularize your code through the use of methods to isolate some functionality of your choice. Your application should be interactive with the user. // a form must be displayed to the user providing the user with fields to be filled and/or buttons that they should click to be provided with some result/answer to some problem. //

You should add validation AND exception handling IF the application involves input from the user in the form.

write an application that includes functionality for reading a file in order to populate the array.

This is what i had in mind. Add the students and their GPA. Students selected in the drop down and they display in the three labels. Being able to update students. Calculate the Class average and exit.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace inp_valid_class_avg
{
public partial class Form1 : Form
{
String[] lname = new String[10];
String[] fname = new String[10];
double[] gpa = new double[10];
static int i = 0;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
lname[i] = textBox1.Text;
}
else
{
textBox1.Focus();
}

if(textBox2.Text !="")
{
fname[i]=textBox2.Text ;
}
else
{
textBox2.Focus();
}
if (textBox3.Text != "")
{
gpa[i] = Convert.ToDouble(textBox3.Text);
}
else
{
textBox3.Focus();
}
i++;
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox1.Focus();

}

private void button3_Click(object sender, EventArgs e)
{
double av=0,sum=0;

for (int j = 0; j < i; j++)
{
sum = sum + gpa[j];
}
av = sum / i;
textBox4.Text = av.ToString();

}

private void button2_Click(object sender, EventArgs e)
{
Close();
}
}
}