JulianJulianov

08.MethodsLab-Math Power

Feb 13th, 2020
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. 8. Math Power
  2. Create a method that calculates and returns the value of a number raised to a given power:
  3. Examples
  4. Input   Output
  5. 2
  6. 8       256
  7. 3
  8. 4       81
  9. Hints
  10. 1.  As usual, read the input
  11. 2.  Create a method which will have two parameters - the number and the power, and will return a result of type double:
  12. 3.  Print the result
  13.  
  14. using System;
  15.  
  16. namespace _08MathPower
  17. {
  18.     class Program
  19.     {
  20.         static void Main(string[] args)
  21.         {
  22.             var number = int.Parse(Console.ReadLine());
  23.             var power = int.Parse(Console.ReadLine());
  24.             double raiseToPower = NewMethod(number, power);
  25.             Console.WriteLine(raiseToPower);
  26.         }
  27.  
  28.         private static double NewMethod(int number, int power)
  29.         {
  30.             double calculation = 0.0;// Вместо 0.0 , може 0d.
  31.             calculation = Math.Pow(number, power);
  32.             return calculation;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment