Q:

Write an application named SumInts that allows the user to enter any number of integers continuously until the user enters 999. Display the sum of the values entered, not including 999

0

Write an application named SumInts that allows the user to enter any number of integers continuously until the user enters 999. Display the sum of the values entered, not including 999.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace SumInts
{
    class SumInts
    {
        static void Main(string[] args)
        {
            WriteLine("SumInts");
            int count = 0;
            int entry = 0;
            int sum = 0;
            while (entry != 999) //backup check
            {
                count++;
                Write("Enter number {0}:", count);
                entry = int.Parse(ReadLine());
                if (entry == 999) break;
                sum += entry;
            }
            WriteLine("Sum:{0}", sum);

            WriteLine("--End--");
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now