0% found this document useful (0 votes)
2 views5 pages

14# Classes & Modifiers

The document outlines a C# program with classes for arithmetic operations and constants. It includes methods for addition, subtraction, multiplication, and division, as well as constants for PI and gravity. The program demonstrates the use of these classes in a main method to perform calculations and display results.

Uploaded by

Lesunter KLter
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)
2 views5 pages

14# Classes & Modifiers

The document outlines a C# program with classes for arithmetic operations and constants. It includes methods for addition, subtraction, multiplication, and division, as well as constants for PI and gravity. The program demonstrates the use of these classes in a main method to perform calculations and display results.

Uploaded by

Lesunter KLter
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/ 5

14# Classes & Modifiers

using System;
namespace darklter
{
class Program
{
static int add = 0;
static void Main(string[] args)
{

}
}

class Arithmetic
{
int add = 0;
}

class Constants
{
int add = 0;
}
}

//
OR/////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////

[( Solution Explorer > NAME OF PROJECT > *R click > Add > New Item > Class >
*(NAME) > Then *(ADD) )]

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||

//////////////////
//Arithmetic.cs//
\\\\\\\\\\\\\\\\\

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace darklter
{
internal class Arithmetic
{
public int add(int num1, int num2)
{
return num1 + num2;
}

public int subtract(int num1, int num2)


{
return num1 - num2;
}

public int multiply(int num1, int num2)


{
return num1 * num2;
}

public int divide(int num1, int num2)


{
return num1 / num2;
}
}
}

/////////////////
//Constants.cs//
\\\\\\\\\\\\\\\\

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace darklter
{
internal class Constants
{
public float PI = 3.14f;
public float GRAVITY = 9.8f;
}
}

///////////////
//Program.cs//
\\\\\\\\\\\\\\

using System;
namespace darklter
{
class Program
{
static int add = 0;
static void Main(string[] args)
{
Arithmetic a = new Arithmetic();
Constants c = new Constants();

Console.WriteLine(a.add(5,2));
Console.WriteLine(a.subtract(5,2));
Console.WriteLine(a.multiply(5,2));
Console.WriteLine(a.divide(6,2));
Console.WriteLine(c.PI);
Console.WriteLine(c.GRAVITY);
}
}
}

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||

//////////////////
//Arithmetic.cs//
\\\\\\\\\\\\\\\\\

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace darklter
{
static class Arithmetic
{
public static int add(int num1, int num2)
{
return num1 + num2;
}

public static int subtract(int num1, int num2)


{
return num1 - num2;
}

public static int multiply(int num1, int num2)


{
return num1 * num2;
}

public static int divide(int num1, int num2)


{
return num1 / num2;
}
}
}

/////////////////
//Constants.cs//
\\\\\\\\\\\\\\\\

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace darklter
{
static class Constants
{
public static float PI = 3.14f;
public static float GRAVITY = 9.8f;
}
}

//
#readolny//////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace darklter
{
static class Constants
{
public static readonly float PI = 3.14f;
public static readonly float GRAVITY = 9.8f;
}
}

///////////////
//Program.cs//
\\\\\\\\\\\\\\

using System;
namespace darklter
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Arithmetic.add(5, 2));
Console.WriteLine(Constants.PI);
}
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy