Find Square and Cube C# Handson Solution Cognizant
Write a C# Program to compute the square and Cube for a given number.
Create the following methods.
- Create a method FindSquare that returns the square of the given number.
FindSquare method should accept a single parameter of type double and return a double value
- Create a method FindCube that returns the cube of the given number.
FindCube method should accept a single parameter of type double and return a double value
From the main method prompt the user to enter a number and display the square and cube of the number.
The method signature should be as below
static < return type> <FunctionName> ( <data type> parameter)
Sample Input
Enter a Number
4
Sample Output
Square of 4 is 16
Cube of 4 is 64
Program.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Methods2 //DO NOT Change namespace name { public class Program //DO NOT Change class 'Program' name { public static void Main(string[] args) //DO NOT Change 'Main' method Signature { //Implement your code here Console.WriteLine("Enter a Number"); double number=Convert.ToDouble(Console.ReadLine()); double squarenumber=FindSquare(number); double cubenumber=FindCube(number); Console.WriteLine("Square of "+number+" is "+squarenumber); Console.WriteLine("Cube of "+number+" is "+cubenumber); } //Implement methods here. Keep the method 'public' and 'static' static double FindSquare(double num){ return num*num; } static double FindCube(double num){ return num*num*num; } } }