Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exercise 1 Introduction to C# CIS-2320. 2 Code the C# program to prompt the user to key in 12 integer values from the keyboard. If a value containing.

Similar presentations


Presentation on theme: "Exercise 1 Introduction to C# CIS-2320. 2 Code the C# program to prompt the user to key in 12 integer values from the keyboard. If a value containing."— Presentation transcript:

1 Exercise 1 Introduction to C# CIS-2320

2 2 Code the C# program to prompt the user to key in 12 integer values from the keyboard. If a value containing invalid characters is detected, display an error message, and skip the value. If a negative value is detected, display an error message, and skip the value. If a value greater than 3 digits (999) is detected, display an error message, and skip the value. When 12 valid values have been entered:   Display the sum of the values entered   Display the largest and smallest value entered   Display the average of the values entered to the nearest 2 decimal places

3 3 Sample program output: Enter a 1 to 3 digit number: 345 Enter a 1 to 3 digit number: 55 Enter a 1 to 3 digit number: 999 Enter a 1 to 3 digit number: -44 Error: Value entered is negative Enter a 1 to 3 digit number: 674323 Error: Value entered is greater than 999 Enter a 1 to 3 digit number: 1 Enter a 1 to 3 digit number: abc Error: Data entered contains invalid characters Enter a 1 to 3 digit number: 4 Enter a 1 to 3 digit number: 77 Enter a 1 to 3 digit number: 444 Enter a 1 to 3 digit number: -5 Error: Value entered is negative Enter a 1 to 3 digit number: 789 Enter a 1 to 3 digit number: 34 Enter a 1 to 3 digit number: 500 Enter a 1 to 3 digit number: 22 Enter a 1 to 3 digit number: 56 Sum of all values.....: 3326 Largest value is......: 999 Smallest value is.....: 1 Average of the values.: 277.17

4 4 Extra Points: 2 points: Create a class with all processing code in the constructor, then create an instance of this class in Main() calling it's constructor. Also create a DisplayTotals() method to display the total lines. Call this method from Main(). This class should be in a separate.cs file. Main() should look as follows: static void Main() { xxxxx ob = new xxxxx(); ob.DisplayTotals(); } 2 points: Display all error messages using the MessageBox class.


Download ppt "Exercise 1 Introduction to C# CIS-2320. 2 Code the C# program to prompt the user to key in 12 integer values from the keyboard. If a value containing."

Similar presentations


Ads by Google