Вы находитесь на странице: 1из 7

LPU

ASSIGNMENT
NO1 OF
MODERN
PROGRAMMING
TOOLS &
TECHNIQUES III
SUBMITTED TO

SUBMITTED BY
LPU
ASSIGNMENT
NO1 OF
MODERN
PROGRAMMING
TOOLS &
TECHNIQUES III
SUBMITTED TO SUBMITTED BY

DEEPAK MEHTA VARUN KATOCH

E3801B53
BCA-MCA

Q1. Create a program to sort the elements in ascending and descending


order that is entered by the user.

Ans 1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

Dim num1, num2, num3 As Integer

num1 = TextBox1.Text

num2 = TextBox2.Text

num3 = TextBox3.Text

Q2. Create a program that displays factorial of a number which is


entered by the user using user defined function.

ANS 2 Public Class Form2


Dim num As Integer

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Dim fact As Integer

num = Val(InputBox("Enter the Factorial Number"))

Do
fact = fact * num
num = num - 1

Loop Until num <= 0

MessageBox.Show(fact)
End Sub
End Class

Q3 Create a program that implements the following operation:

(1)To find the length of a string

(2) To find the indexof of the nth position of the string

(3)To split the string using a character.

(4)To use the endswith for a string

Ans (1)

Dim r As Integer
TextBox1.Text = "Welcome to the grand parade"
TextBox2.text = "grand"
r = TextBox1.Text.IndexOf(TextBox2.Text)
If r > 0 Then
MsgBox("Found word, " & r & " characters into the search string.")
Else
MsgBox("Sorry, could not find the search text")
End If
(3) Dim i As String = "Line 0|Line 1|Line 2|Line 3"
Dim a() As String
Dim j As Integer
a = i.Split("|")
For j = 0 To a.GetUpperBound(0)
MsgBox(a(j))
Next

Q4 Write a Program that implements Date and Time Functions, string &

mathematical functions

Ans 4 $st = time(); // gets the current time in unix timestamp

$current_month_full = date("F"); // gets full length month like January, December

$current_month_short = date("M"); // gets abbreviated month like Jan, Dec

$current_month_num_zero = date("m"); // gets current month number with


leading 0 like 01, 02

$current_month_num = date("n"); // gets the current month number without


leading 0 like 1, 2, 3
// now you need to check against some entered month for example

if($_GET['monthdata'] == $current_month_full){

echo "The month matches the current month!";

}else{

echo "The month does not match the current month!";

Q6. Create a program that implements inheritance using an employee


base class and manager derived class. You can use any data and
methods for compilation of the inheritance.

Ans 6

class Counter {

int i = 0;

public Counter()

i=1;

Counter increment() {

i++;

return this;

void print() {

System.out.println("i = " + i);

public class CounterDemo extends Counter{


public static void main(String[] args) {

Counter x = new Counter();

x.increment().increment().increment().print();

import java.io.*;

class Base

int i;

public Base(int i)

nb {

this.i=i;

public void print()

System.out.println("Value of i "+i);

public class MainClass extends Base

int i;

public static void main(String[] args)

MainClass m=new MainClass();


}

Вам также может понравиться