[go: up one dir, main page]

0% found this document useful (0 votes)
17 views7 pages

Console Application Process With Example

The document provides instructions for creating and running console applications in C# and VB.Net, detailing steps for both Command Prompt and Visual Studio IDE. It includes example code for an Employee class that calculates and displays salary details, including basic salary, allowances, and net salary. The examples demonstrate the use of parameterized constructors and methods for calculation and output of employee details.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views7 pages

Console Application Process With Example

The document provides instructions for creating and running console applications in C# and VB.Net, detailing steps for both Command Prompt and Visual Studio IDE. It includes example code for an Employee class that calculates and displays salary details, including basic salary, allowances, and net salary. The examples demonstrate the use of parameterized constructors and methods for calculation and output of employee details.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Console Application

1. In Command Prompt
a. Go to Command Prompt
b. Write program using Editor(Notepad)
c. Save it (.vb/.cs)
d. Compilation (C:\>vbc f1.fb or C:\>vbc f1.cs), It will create .Exe file
(f1.Exe)
e. Run it (C:\>f1 )
2. IDE
a. Open Visual Studio
b. Click-File->New->Project->Visual Basic/Visual C#->Type is Console
Application
c. Write program, Save it and Run it (F5 or click->Start Debuging Button)

Console Application Examples using C#.Net


Example:-I (Program.cs)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication14
{
class Employee //My Class and My codes
{
//Data members
private int id;
private string name;
private DateTime joinDt;
private double basicSalary;
private double da;
private double hr;
private double grossSalary;
private double it;
private double netSalary;
//Methods
public void calCulate()
{
this.da = this.basicSalary * 0.3; //30% of basicSalary
this.hr = this.basicSalary * 0.15; //15% of basicSalary
this.grossSalary = this.basicSalary + this.da + this.hr;
this.it = this.grossSalary * 0.1; //10% of grossSalary
this.netSalary = this.grossSalary - this.it;
}
public void showEmployeeDetail()
{
System.Console.WriteLine("");
System.Console.WriteLine("Employee Detail");
System.Console.WriteLine("===============");
System.Console.WriteLine("Id :" + this.id);
System.Console.WriteLine("Name :" + this.name);
System.Console.WriteLine("Jaoining Date :" + this.joinDt);
System.Console.WriteLine("Basic Salary :" + this.basicSalary);
System.Console.WriteLine("Daily Allowance(30% of Basic Salary) :" + this.da);
System.Console.WriteLine("House Rent (15% of Basic Salary) :" + this.hr);
System.Console.WriteLine("Gross Salary(Basic Salary+DA+HR) :" + this.grossSalary);
System.Console.WriteLine("Income Tax (10% of Gross Salary) :" + this.it);
System.Console.WriteLine("Net Payble Salary (Gross Salay - Income Tax) :" +
this.netSalary);

}
class Program
{
static void Main(string[] args)
{
Employee e1 = new Employee(); //Create object of Employee
e1.calCulate();
e1.showEmployeeDetail();
System.Console.ReadKey();

}
}
}
Output

Example:-II (Program.cs)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication14
{
class Employee //My Class and My codes
{
private int id;
private string name;
private DateTime joinDt;
private double basicSalary;
private double da;
private double hr;
private double grossSalary;
private double it;
private double netSalary;
public Employee(int prmId, string prmName, DateTime prmJoinDt, double
prmBasicSalary) //Parameterized Constructor
{
this.id = prmId;
this.name = prmName;
this.joinDt = prmJoinDt;
this.basicSalary = prmBasicSalary;
}
public void calCulate()
{
this.da = this.basicSalary * 0.3; //30% of basicSalary
this.hr = this.basicSalary * 0.15; //15% of basicSalary
this.grossSalary = this.basicSalary + this.da + this.hr;
this.it = this.grossSalary * 0.1; //10% of grossSalary
this.netSalary = this.grossSalary - this.it;
}
public void showEmployeeDetail()
{
System.Console.WriteLine("");
System.Console.WriteLine("Employee Detail");
System.Console.WriteLine("===============");
System.Console.WriteLine("Id :" + this.id);
System.Console.WriteLine("Name :" + this.name);
System.Console.WriteLine("Jaoining Date :" + this.joinDt.ToString("dd/MM/yyyy"));
int wYear = DateTime.Now.Year - this.joinDt.Year;
System.Console.WriteLine("Year of Working :" + wYear);
System.Console.WriteLine("Basic Salary :" + this.basicSalary);
System.Console.WriteLine("Daily Allowance(30% of Basic Salary) :" + this.da);
System.Console.WriteLine("House Rent (15% of Basic Salary) :" + this.hr);
System.Console.WriteLine("Gross Salary(Basic Salary+DA+HR) :" + this.grossSalary);
System.Console.WriteLine("Income Tax (10% of Gross Salary) :" + this.it);
System.Console.WriteLine("Net Payble Salary (Gross Salay - Income Tax) :" +
this.netSalary);

}
class Program
{
static void Main(string[] args)
{
DateTime jDt = new DateTime(2000, 7, 29, 0, 0, 0);
Employee e1 = new Employee(1,"Rudra Prasad Dash",jDt,500); //My codes
e1.calCulate();
e1.showEmployeeDetail();
System.Console.ReadKey();

}
}
}

Output
Console Application Examples using VB.Net
Example-I (Module1.vb)
Imports System.Console
Module Module1
Class Employee
'Data Members
Private id As Integer
Private name As String
Private joinDt As DateTime
Private basicSalary As Double
Private da As Double
Private hr As Double
Private grossSalary As Double
Private it As Double
Private netSalary As Double

'Procedure (Do't return any value)


Public Sub calCulate()
Me.da = Me.basicSalary * 0.3 '0% of basicSalary
Me.hr = Me.basicSalary * 0.15 '15% of basicSalary
Me.grossSalary = Me.basicSalary + Me.da + Me.hr
Me.it = Me.grossSalary * 0.1 '10% of grossSalary
Me.netSalary = Me.grossSalary - Me.it
End Sub

Public Sub showEmployeeDetail()


WriteLine("")
WriteLine("Employee Detail")
WriteLine("===============")
WriteLine("Id :" & Me.id)
WriteLine("Name :" & Me.name)
WriteLine("Jaoining Date :" & Me.joinDt)
WriteLine("Basic Salary :" & Me.basicSalary)
WriteLine("Daily Allowance(30% of Basic Salary) :" & Me.da)
WriteLine("House Rent (15% of Basic Salary) :" & Me.hr)
WriteLine("Gross Salary(Basic Salary+DA+HR) :" & Me.grossSalary)
WriteLine("Income Tax (10% of Gross Salary) :" & Me.it)
WriteLine("Net Payble Salary (Gross Salay - Income Tax) :" &
Me.netSalary)

End Sub
End Class

Sub Main()
Dim e1 As New Employee() 'Create object of Employee
e1.calCulate()
e1.showEmployeeDetail()
System.Console.ReadKey()
End Sub

End Module
Output

Example-II (Module1.vb)
Imports System.Console
Module Module1
Class Employee
'Data Members
Private id As Integer
Private name As String
Private joinDt As DateTime
Private basicSalary As Double
Private da As Double
Private hr As Double
Private grossSalary As Double
Private it As Double
Private netSalary As Double

Public Sub New(prmId As Integer, prmName As String, prmJoinDt As


DateTime, prmBasicSalary As Double) 'Parameterized Constructor
Me.id = prmId
Me.name = prmName
Me.joinDt = prmJoinDt
Me.basicSalary = prmBasicSalary
End Sub

'Procedure (Do't return any value)


Public Sub calCulate()
Me.da = Me.basicSalary * 0.3 '0% of basicSalary
Me.hr = Me.basicSalary * 0.15 '15% of basicSalary
Me.grossSalary = Me.basicSalary + Me.da + Me.hr
Me.it = Me.grossSalary * 0.1 '10% of grossSalary
Me.netSalary = Me.grossSalary - Me.it
End Sub

Public Sub showEmployeeDetail()


WriteLine("")
WriteLine("Employee Detail")
WriteLine("===============")
WriteLine("Id :" & Me.id)
WriteLine("Name :" & Me.name)
WriteLine("Jaoining Date :" & Me.joinDt.ToString("dd/MM/yyyy"))
Dim wYear As Integer = DateTime.Now.Year - Me.joinDt.Year
WriteLine("Year of Working :" & wYear)
WriteLine("Basic Salary :" & Me.basicSalary)
WriteLine("Daily Allowance(30% of Basic Salary) :" & Me.da)
WriteLine("House Rent (15% of Basic Salary) :" & Me.hr)
WriteLine("Gross Salary(Basic Salary+DA+HR) :" & Me.grossSalary)
WriteLine("Income Tax (10% of Gross Salary) :" & Me.it)
WriteLine("Net Payble Salary (Gross Salay - Income Tax) :" &
Me.netSalary)
End Sub
End Class

Sub Main()
Dim jDt As New DateTime(2000, 7, 29, 0, 0, 0)
Dim e1 As New Employee(1, "Rudra Prasad Dash", jDt, 500) 'Create object
of Employee
e1.calCulate()
e1.showEmployeeDetail()
System.Console.ReadKey()
End Sub

End Module

Output

You might also like