Advertisement
Cnvmendoza

Method_5_6

Mar 26th, 2024
735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | Source Code | 0 0
  1. public static int CalculateSumOfCubes()
  2. {
  3.     Console.Write("Input Number of Inputs: ");
  4.     int number_of_inputs = Convert.ToInt32(Console.ReadLine());
  5.     int sum = 0;
  6.     for (int i = 0; i < number_of_inputs; i++)
  7.     {
  8.         Console.Write("Input Number: ");
  9.         int input = Convert.ToInt32(Console.ReadLine());
  10.         sum += input * input * input;
  11.     }
  12.     return sum;
  13. }
  14.  
  15. public static double CalculateAverage()
  16. {
  17.     Console.Write("Input Number of Inputs: ");
  18.     int number_of_inputs = Convert.ToInt32(Console.ReadLine());
  19.     double average = 0;
  20.     int sum = 0;
  21.     for (int i = 0; i < number_of_inputs; i++)
  22.     {
  23.         Console.Write("Input Number: ");
  24.         int input = Convert.ToInt32(Console.ReadLine());
  25.         sum += input;
  26.     }
  27.     average = sum / number_of_inputs;
  28.     return average;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement