0% found this document useful (0 votes)
284 views

BCA JAVA & .NET Practical File

The document contains 12 programs written in Java and C# to demonstrate basic programming concepts like printing output, performing arithmetic operations, conditional statements, and loops. Each program is accompanied by its corresponding output.

Uploaded by

Tinku Budhwar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
284 views

BCA JAVA & .NET Practical File

The document contains 12 programs written in Java and C# to demonstrate basic programming concepts like printing output, performing arithmetic operations, conditional statements, and loops. Each program is accompanied by its corresponding output.

Uploaded by

Tinku Budhwar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

PRACTICAL FILE

ON
SOFTWARE LAB
Using JAVA & .NET
(BCA-310)

BACHELOR OF COMPUTER APPLICATIONS


VAISH COLLEGE OF ENGINEERING ROHTAK

Submitted To: Submitted By:


Dr. Tarun Dalal NAME:
AP, CSE Deptt. ROLL NO:
Vaish College of Engineering CLASS:
Rohtak

Page 1
INDEX

S. NO. EXPERIMENT SIGNATURE

1 WRITE A PROGRAM TO PRINT HELLO USING


JAVA

2 WRITE A PROGRAM FOR SUM OF TWO


NUMBERS USING JAVA

3 WRITE A PROGRAM FOR ADDITION OF TWO


NUMBERS USING SCANNER IN JAVA

4 WRITE A PROGRAM TO FIND LARGEST OF


TWO NUMBERS USING JAVA

5 WRITE A PROGRAM TO CHECK IF A GIVEN


INTEGER IS ODD OR EVEN USING JAVA
6 WRITE A PROGRAM FOR MULTILEVEL
INHERITANCE USING JAVA

7 WRITE A PROGRAM TO PRINT HELLO IN C#

8 WRITE A PROGRAM TO PERFORM


ARITHMETIC OPERATION IN C#

9 WRITE A PROGRAM TO PERFORM IF ELSE


STATEMENT IN C#

10 WRITE A PROGRAM TO PERFORM WHILE


LOOP IN C#

11 WRITE A PROGRAM TO PERFORM DO WHILE


LOOP IN C#

12 WRITE A PROGRAM TO PERFORM FOR LOOP


IN C#

Page 2
PROGRAM 1

AIM - WRITE A PROGRAM TO PRINT HELLO USING JAVA

class hello

public static void main(String arg[])

System.out.println("hello");

}}

Page 3
OUTPUT

Page 4
PROGRAM 2

AIM – WRITE A PROGRAM FOR SUM OF TWO NUMBERS USING


JAVA

public class AddTwoNumbers

public static void main(String[]args)

int num1 = 5, num2 = 15, sum;

sum=num1+num2;

System.out.println("sum of these numbers: "+sum);

Page 5
OUTPUT

Page 6
PROGRAM 3

AIM - WRITE A PROGRAM FOR ADDITION OF TWO NUMBERS


USING SCANNER IN JAVA

import java.util.Scanner;

class Addition

public static void main(String args[])

Scanner in=new Scanner(System.in);

System.out.println("Enter value 1:");

int a=in.nextInt();

System.out.println("Enter value 2:");

int b=in.nextInt();

int c=a+b;

System.out.println("Sum:"+c);

Page 7
OUTPUT

Page 8
PROGRAM 4

AIM - WRITE A PROGRAM TO FIND LARGEST OF TWO NUMBERS


USING JAVA

import java.util.Scanner;

public class LargestofTwo

private static Scanner sc;

public static void main(String[]args)

int number1, number2;

sc=new Scanner(System.in);

System.out.println("Please Enter The First Number:");

number1=sc.nextInt();

System.out.println("Please Enter The Second Number:");

number2=sc.nextInt();

if(number1 > number2)

System.out.println("\n The Largest Number=" +number1);

else if(number2 > number1)

System.out.println("\n The Largest Number=" +number2);

Page 9
}

else

System.out.println("\nBoth are Equal");

Page
10
OUTPUT

Page
11
PROGRAM 5

AIM - WRITE A PROGRAM TO CHECK IF A GIVEN INTEGER IS ODD


OR EVEN USING JAVA

import java.util.Scanner;

public class Odd_Even

public static void main(String[]args)

int n;

Scanner s =new Scanner(System.in);

System.out.print("Enter the number you want to check:");

n=s.nextInt();

if(n%2==0)

System.out.println("The given number "+n+" is Even");

else

System.out.println("The given number "+n+" is Odd");

Page
12
OUTPUT

Page
13
PROGRAM 6

AIM – WRITE A PROGRAM FOR MULTILEVEL INHERITANCE


USING JAVA

class Car

public Car()

System.out.println("class Car");

public void vehicleType()

System.out.println("Vehicle Type: Car");

class Maruti extends Car

public Maruti()

System.out.println("class Maruti");

public void brand()

Page
14
System.out.println("Brand: Maruti");

public void speed()

System.out.println("Max: 90kmph");

public class Maruti800 extends Maruti

public Maruti800()

System.out.println("Maruti Model: 800");

public void speed()

System.out.println("Max: 80kmph");

public static void main(String args[])

Maruti800 obj=new Maruti800();

obj.vehicleType();

obj.brand();

obj.speed();

Page
15
}

OUTPUT

Page
16
PROGRAM 7

AIM - WRITE A PROGRAM TO PRINT HELLO IN C#

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

namespace ConsoleApplication12
{
classProgram
{
staticvoid Main()
{
Console.WriteLine("Hello World!!");
Console.ReadKey();

}
}

Page
17
OUTPUT

Page
18
PROGRAM 8

AIM - WRITE A PROGRAM TO PERFORM ARITHMETIC


OPERATION IN C#

using System;

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

namespace ConsoleApplication13
{
classProgram
{
staticvoid Main(string[] args)
{
int num1, num2;
int add, sub;
Console.WriteLine("Enter first number:");
num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\n\nEnter second number:");
num2 = Convert.ToInt32(Console.ReadLine());
add = num1 + num2;
sub = num1 - num2;

Console.WriteLine("\n\n================\n");
Console.WriteLine("Addition{0}",add);
Console.WriteLine("Subtraction{0}", sub);
Console.WriteLine("\n\n================\n");
Console.ReadLine();

}
}
}

Page
19
OUTPUT

Page
20
PROGRAM 9

AIM - WRITE A PROGRAM TO PERFORM IF ELSE STATEMENT IN


C#

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

namespace ConsoleApplication14
{
class Program
{
public static void Main(string[] args)
{
int a = 10;
if (a < 5)
{
Console.WriteLine("{0} is less than 5", a);
}
else
{
Console.WriteLine("{0} is greater than or equal to 5", a);

}
Console.ReadKey();

}
}
}

Page
21
OUTPUT

Page
22
PROGRAM 10

AIM – WRITE A PROGRAM TO PERFORM WHILE LOOP IN C#

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

namespace ConsoleApplication15
{
class Program
{
static void Main(string[] args)
{
int i = 0;
while (i < 10)
{
Console.WriteLine("The value of i: {0}", i);
i++;
}

Console.ReadKey();
}
}
}

Page
23
OUTPUT

Page
24
PROGRAM 11

AIM – WRITE A PROGRAM TO PERFORM DO WHILE LOOP IN C#

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

namespace ConsoleApplication16
{
class abc
{
public static void Main(string[] args)
{
int i = 1;
int n = 5;
int product;
do
{
product = n * i;
Console.WriteLine("{0} * {1} = {2}", n, i, product);
i++;

}
while (i <= 10);
Console.ReadKey();
}

Page
25
OUTPUT

Page
26
PROGRAM 12

AIM - WRITE A PROGRAM TO PERFORM FOR LOOP IN C#

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

namespace ConsoleApplication17
{
class Bca
{
public static void Main(string[] args)
{
for (int i = 1; i <= 5; i++)
Console.WriteLine("C# For Loop:Iteration {0}", i);
Console.ReadKey();
}
}
}

Page
27
OUTPUT

Page
28

You might also like