0

Here is the dilemna, I can't figure out how to count the time a value is above a certain amount in c#.

Exercise:
A radio station specialized in classical music is raising fund. People call in to pledge donations. Donors who pledge for $100 or above will receive a coffee mug. The radio station wants a program to tell them how many coffee mugs they need. The program will ask for the amount pledged by each donor. When there is no more pledge to enter, input -1 to stop data entry. The program should display the number of pledges that are $100 or above.

Current code:

using System;

public class Question03
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Mugs Need for Donations over $100") ;
        Console.WriteLine("=================================");
        Console.WriteLine();

        int pledge;
        int totalPledges = 0;
        int numMugs = 0;

        Console.Write("Enter the amount to be pledged or -1 to stop: ");
        pledge = Convert.ToInt32(Console.ReadLine());
        while (pledge != -1)
            {
            totalPledges = totalPledges + pledge;
            //numMugs = numMugs + 1;
            Console.Write("Enter the amount to be pledged or -1 to stop: "); 
            pledge = Convert.ToInt32(Console.ReadLine());
        }
        Console.WriteLine("Total amount pledged: {0}", totalPledges); 
        //Console.WriteLine("Number of pledges: { 0}", numStudents);
        for (pledge = 0; pledge > 100)
        {
            Console.WriteLine("Number of Mugs: {0}", pledge);
        }
    }
}

Edited by Reverend Jim: Moved to programming forum

2
Contributors
2
Replies
11
Views
9 Months
Discussion Span
Last Post by Karl_6
0

Rev. Jim,

Thanks! I figured it had to do with something like that but I didn't know how to write it. Thanks again. Ha! Feels good when things are solved.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.