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

LPU Programming Assignment Solutions

This document contains answers to 6 questions about programming in modern tools and techniques. It includes programs to: sort numbers in ascending and descending order; calculate factorials using a user-defined function; implement string and date/time functions; split a string using a character; and demonstrate inheritance using an Employee base class and Manager derived class. The programs cover arrays, conditionals, loops, classes, and inheritance.

Uploaded by

Ankur Singh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views7 pages

LPU Programming Assignment Solutions

This document contains answers to 6 questions about programming in modern tools and techniques. It includes programs to: sort numbers in ascending and descending order; calculate factorials using a user-defined function; implement string and date/time functions; split a string using a character; and demonstrate inheritance using an Employee base class and Manager derived class. The programs cover arrays, conditionals, loops, classes, and inheritance.

Uploaded by

Ankur Singh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

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 [Link], ByVal e As


[Link]) Handles [Link]

Dim num1, num2, num3 As Integer

num1 = [Link]

num2 = [Link]

num3 = [Link]

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 [Link], ByVal e As


[Link]) Handles [Link]
Dim fact As Integer

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

Do
fact = fact * num
num = num - 1

Loop Until num <= 0

[Link](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
[Link] = "Welcome to the grand parade"
[Link] = "grand"
r = [Link]([Link])
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 = [Link]("|")
For j = 0 To [Link](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() {

[Link]("i = " + i);

public class CounterDemo extends Counter{


public static void main(String[] args) {

Counter x = new Counter();

[Link]().increment().increment().print();

import [Link].*;

class Base

int i;

public Base(int i)

nb {

this.i=i;

public void print()

[Link]("Value of i "+i);

public class MainClass extends Base

int i;

public static void main(String[] args)

MainClass m=new MainClass();


}

You might also like