public int arrayrange = 0;
public int[] numberArray = new int[10];
public int highest, lowest;
public double squaresum = 0, sumPrimeSquared = 0, EvenCubedSum = 0, sum456 = 0;
public string getArraySize()
Console.WriteLine("\nPlease input the size of the Array :");
var range = Console.ReadLine();
try{ while (string.IsNullOrEmpty(range) || Int32.Parse(range) < 3 || Int32.Parse(range) > 10)
Console.WriteLine("Number of items has to be more than 2 and cannot be more than 10! \nPlease input the size of the Array again :");
range = Console.ReadLine();
catch (System.FormatException) {
public void setArrayItems()
Console.WriteLine("\nPlease input Array items :");
for(var i=0;i<arrayrange;i++){
var item = Console.ReadLine();
try{ while (string.IsNullOrEmpty(item) || Int32.Parse(item) < 1 || Int32.Parse(item) > 100)
Console.WriteLine("Please enter numbers only in the range of 1 and 100");
item = Console.ReadLine();}
numberArray[i] = Int32.Parse(item);
catch(System.FormatException) {
Console.WriteLine("Invalid Values Provided.");
Console.WriteLine("\nArray items are as follows :");
for(var i=0;i<arrayrange;i++){
Console.WriteLine("{0}",numberArray[i]);
for(var i=0;i<arrayrange;i++){
Console.WriteLine("\n1. Sum of Array Items : {0}", sum);
public void computeHighest()
highest = numberArray[0];
for(var i=1;i<arrayrange;i++){
if(highest < numberArray[i])
highest = numberArray[i];
Console.WriteLine("\n2. Highest Array Item : {0}", highest);
public void computeLowest()
for(var i=1;i<arrayrange;i++){
if(lowest > numberArray[i])
Console.WriteLine("\n3. Lowest Array Item : {0}", lowest);
public void squareHighLow()
squaresum = Math.Pow(highest,2) + Math.Pow(lowest,2);
Console.WriteLine("\n4. Sum of squares of (2) and (3): {0}", squaresum);
public void sumSquarePrime()
for(var i=0;i<arrayrange;i++){
for(var j=2;j<=numberArray[i]/2;j++){
if(numberArray[i] % j == 0)
sumPrimeSquared += Math.Pow(numberArray[i],2);
Console.WriteLine("\n5. Sum of squares of all primes : {0}", sumPrimeSquared);
public void sumCubeEven()
for(var i=0;i<arrayrange;i++){
if(numberArray[i] % 2 == 0)
EvenCubedSum += Math.Pow(numberArray[i],3);
Console.WriteLine("\n6. Sum of cubes of all evens : {0}", EvenCubedSum);
sum456 = squaresum + sumPrimeSquared + EvenCubedSum;
Console.WriteLine("\n7. Sum of (4), (5) and (6) : {0}", sum456);
Console.WriteLine("\n8. Square root of (7) : {0}", Math.Sqrt(sum456));
public static void Main()
Console.WriteLine("## Number Computation ##\n");
Program p = new Program();
p.arrayrange = Int32.Parse(p.getArraySize());
Console.WriteLine("\n## Computation Results ##\n");
catch (System.FormatException) {
Console.WriteLine("Invalid Values Provided.");