Advertisement
kyamaliev

C#Basics HW4 Problem7

Mar 25th, 2014
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. using System;
  2. class SumOfFiveNumbers
  3. {
  4.     static void Main()
  5.     {
  6.         Console.Write("Please input 5 numbers, separated by space: ");
  7.         string[] userInput = Console.ReadLine().Split();
  8.         double[] numbers = new double[5];
  9.         double sum = 0;
  10.         for (int i = 0; i < 5; i++)
  11.         {
  12.             numbers[i] = double.Parse(userInput[i]);
  13.             sum += numbers[i];
  14.         }
  15.         Console.WriteLine("sum is: " + sum);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement