Hello everyone
I tried to do this with if and else, didnt work.. im trying now with while(true) but im not sure whats the next step, please help me with the following console C# code
The process of finding the largest number (i.e., the maximum of a group of numbers) is used frequently in computer applications. For example, a program that determines the winner of a sales contest inputs the number of units sold by each salesperson. The salesperson who sells the most units wins the contest. Write a C# program that uses a looping statement to determine and print the largest number of 10 numbers input by the user. Your program must use only three variables, as follows: counter: A counter to count to 10 (i.e., to keep track of how many numbers have been input and to determine when all 10 numbers have been processed). number: The current number input to the program. largest: The largest number found so far.
Thanks!
Loading
Prime bPosted Feb 23, 2012, 10:50 AM
john burnsPosted Feb 23, 2012, 12:03 AM
Thank you so much, appreciate it really
Prime bPosted Feb 22, 2012, 5:50 PM
namespace ForumHelp
{
class Program
{
static void Main(string[] args)
{
int counter=0; // assign variables
double largest=0;
double number=0;
while (counter != 10) // use while loop 10 times, once counter = 10 quit
{
counter++;
Console.WriteLine("Please enter the sales amount: ");
number = Convert.ToInt32(Console.ReadLine());
if (largest < number) // find the largest number
{
largest = number;
}
}
Console.WriteLine("Larget number is " + largest); // display the number
Console.ReadLine();
}
}
}