Tuesday, September 25, 2012

How to solve a program in C#.Net

First identify the Inputs of the program & also identify the requirements.

 WriteLine() is used for Output
 ReadLine() is used for Input
 Write() is used for Output

ReadLine() Function accept String data from the user


System is a namespace,which helps us to input and output data from user using different classes.

Namespace is a combination of similar type of classes

Ram basic salary is input through keyboard. His HRA is 50% of basic salary and DA is 20 % of basic salary. Calculate the gross salary?

Step 1. Input the basic salary.

Step 2. Identify the basic thinks needed for Program

 Class
 Main
 System
 Console
 WriteLine
 ReadLine


Sample Program:
using System;
class RamSalary
{
 public static void Main(string [] args)
 {
  double sal,HRA,DA,Grossal;

  Console.WriteLine("Enter Salary: ");
  sal = Convert.ToDouble(Console.ReadLine());\\10000
  HRA = sal * .5;\\5000
  DA = sal * .2;\\2000
  Grossal = sal+ HRA + DA;\\17000 = 10000 + 5000 + 2000
  Console .WriteLine("Gross Salary is : {0}",Grossal);
\\17000
 }
}

No comments: