Advertisement
Gesh4o

PrintSumOfFiveCheckedNumbers

Sep 2nd, 2015
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. using System;
  2.  
  3. class SumOfFiveNumbers
  4. {
  5. static void Main()
  6. {
  7. System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
  8. decimal number;
  9. decimal sum = 0;
  10. string input;
  11. for (int i = 1; i <= 5; i++)
  12. {
  13. do
  14. {
  15. input = Console.ReadLine();
  16. }
  17. while (!decimal.TryParse(input, out number));
  18. sum += number;
  19.  
  20. }
  21. Console.WriteLine("The sum is: {0} ", sum);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement