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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
static public class Gradebook
{
static double[] alex = new double[3] { 79, 94, 80 };
static double[] pat = new double[3] { 65, 99, 75 };
static double[] casey = new double[3] { 100, 94, 99 };
static double[] sam = new double[3] { 70, 75, 73 };
static double[] joe = new double[3] { 75, 88, 94 };
static double[] everyone = new double[15] { 79, 94, 80, 75, 88, 94, 70, 75, 73, 100, 94, 99, 65, 99, 75 };
static double[] exam1 = new double[5] { 75, 70, 100, 65, 79 };
static double[] exam2 = new double[5] { 94, 99, 94, 75, 88 };
static double[] exam3 = new double[5] { 75, 80, 94, 73, 99 };
static public double studentAverage()
{
double alexGrade = alex.Average();
double patGrade = pat.Average();
double caseyGrade = casey.Average();
double samGrade = sam.Average();
double joeGrade = joe.Average();
}
static public double examAverage()
{
double exam1Grade = exam1.Average();
double exam2Grade = exam2.Average();
double exam3Grade = exam3.Average();
}
static public double overallAverage()
{
double classGrade = everyone.Average();
}
static private void button1_Click(object sender, EventArgs e)
{
string input = txtRequest.Text;
if (input.Equals("pat", StringComparison.InvariantCultureIgnoreCase))
{
Console.WriteLine("Pat's Average is " + patGrade);
}
else if (input.Equals("alex", StringComparison.InvariantCultureIgnoreCase))
{
Console.WriteLine("Alex's Average is " + alexGrade);
}
else if (input.Equals("casey", StringComparison.InvariantCultureIgnoreCase))
{
Console.WriteLine("Casey's Average is " + caseyGrade);
}
else if (input.Equals("sam", StringComparison.InvariantCultureIgnoreCase))
{
Console.WriteLine("Sam's Average is " + samGrade);
}
else if (input.Equals("joe", StringComparison.InvariantCultureIgnoreCase))
{
Console.WriteLine("Joe's Average is " + joeGrade);
}
else if (input.Equals("exam 1", StringComparison.InvariantCultureIgnoreCase))
{
Console.WriteLine("The class' Average for the first exam is " + exam1Grade);
}
else if (input.Equals("exam 2", StringComparison.InvariantCultureIgnoreCase))
{
Console.WriteLine("The class' Average for the second exam is " + exam2Grade);
}
else if (input.Equals("exam 3", StringComparison.InvariantCultureIgnoreCase))
{
Console.WriteLine("The class' Average for the third exam is " + exam3Grade);
}
else if (input.Equals("class", StringComparison.InvariantCultureIgnoreCase))
{
Console.WriteLine("The class' Average for all three exams is " + classGrade);
}
else
{
Console.WriteLine("Incorrect Input");
}
}
}
}
}
Error 1 'WindowsFormsApplication1.Form1.Gradebook.studentAverage()': not all code paths return a value 44
Error 2 'WindowsFormsApplication1.Form1.Gradebook.examAverage()': not all code paths return a value 53
Error 3 'WindowsFormsApplication1.Form1.Gradebook.overallAverage()': not all code paths return a value 59
Error 4 An object reference is required for the non-static field, method, or property 'WindowsFormsApplication1.Form1.txtRequest' 66
Error 5 The name 'patGrade' does not exist in the current context 69
Error 6 The name 'alexGrade' does not exist in the current context 73
Error 7 The name 'caseyGrade' does not exist in the current context 77
Error 8 The name 'samGrade' does not exist in the current context 81
Error 9 The name 'joeGrade' does not exist in the current context 85
Error 10 The name 'exam1Grade' does not exist in the current context 89
Error 11 The name 'exam2Grade' does not exist in the current context 93
Error 12 The name 'exam3Grade' does not exist in the current context 97
Error 13 The name 'classGrade' does not exist in the current context 101

New Topic/Question
Reply



MultiQuote








|