dimanche 7 février 2016

windows form c# while loop with double variables

currently working on this assignment with a couple classmates http://ift.tt/23RQn7q and having difficulty with the structure of the while loop with the if-else statements. Here is what I currently have under the 'go'button event handler.

private void Go_Click(object sender, EventArgs e)
{
    double startnum = Double.Parse(start.Text);
    double endnum = Double.Parse(end.Text);
    double sumOdd = 0;
    double sumEven = 0;
    double product = 0;
    double allSum = 0;
    double Ecount = 0;
    double Ocount = 0;
    double average = 0;
    while (startnum != endnum)
    {
        {
            if (IsOdd(startnum))
            {
                sumOdd += startnum;
                Ocount++;
            }
            else
            {
                sumEven += startnum;
                Ecount++;
            }
            allSum += startnum;
            product *= startnum;
            startnum++;
        }

Aucun commentaire:

Enregistrer un commentaire