0% found this document useful (0 votes)
4 views2 pages

Matherator Cs

matherator

Uploaded by

Abhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Matherator Cs

matherator

Uploaded by

Abhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

namespace ProgrammingAssignment2
{
/// <summary>
/// Provides a variety of numeric methods
/// </summary>
public class Matherator
{
#region Constructor

/// <summary>
/// Constructor
/// </summary>
public Matherator()
{
}

#endregion

#region Methods

/// <summary>
/// Prints the numbers from 1 to 10
/// </summary>
public void PrintOneToTen()
{
for (int i = 1; i <= 10; i++)
{
Console.Write(i + " ");
}
Console.WriteLine();
}

/// <summary>
/// Prints the numbers from m to n
/// </summary>
/// <param name="m">m</param>
/// <param name="n">n</param>
public void PrintMToN(int m, int n)
{
if (m <= n)
{
for (int i = m; i <= n; i++)
{
Console.Write(i + " ");
}
}
else
{
for (int i = m; i >= n; i--)
{
Console.Write(i + " ");
}
}
Console.WriteLine();
}

/// <summary>
/// Returns the tenth even number, with 2 as the first even number
/// </summary>
/// <returns>tenth even number</returns>
public int GetTenthEvenNumber()
{
return GetNthEvenNumber(10);
}

/// <summary>
/// Returns the nth even number, with 2 as the first even number
/// </summary>
/// <param name="n">n</param>
/// <returns>nth even number</returns>
public int GetNthEvenNumber(int n)
{
return 2 * n;
}

#endregion
}
}

You might also like