Showing posts with label Program. Show all posts
Showing posts with label Program. Show all posts

Saturday, March 6, 2010

# Program 2

Program to input 2 numbers and calculate the sum.

using System;

namespace ConsoleApplication2
{
class Test1
{
static void Main(string[] args)
{
//how to input data from keyboard
//Console.ReadLine() this always input data in string format
// how to convert string data to integer or double
//int a=Convert.ToInt32(Console.ReadLine());
int a, b, c;
Console.WriteLine("Enter the values of a");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the values of b");
b = Convert.ToInt32(Console.ReadLine());

c = a + b;
Console.WriteLine("The asnwer =" + c);
}

}
}

# Program 3

Program to Calculate Simple interest.


using System;

namespace ConsoleApplication2
{
class Test2
{
static void Main(string[] args)
{
double amt, rate, time, Interest;
string name;
Console.WriteLine("Enter the Name ");
name = Console.ReadLine();
Console.WriteLine("Amount ");
amt = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Rate ");
rate = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Time ");
time = Convert.ToDouble(Console.ReadLine());
Interest= (amt * rate * time)/100;
Console.WriteLine("The Interest = " + Interest);
}
}
}

For next tutorial Click the following link:

http://dotnettutions2.blogspot.com