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

MODERN PROGRAMMING TOOLS & TECHNIQUES III

CAP 407 HOMEWORK #1

Submitted TOMR. Sarabjit kumar Sir

Submitted BySangeet Kumar Sant Reg: 10906093 Roll: A 03 SectionRD3902

Part A Q 1. Create a console based application in VB.Net to generate electricity bill after reading new_meter_reading and old_meter_reading from user and apply following charges? units consumed charges < 150 No. Charges > 150 and < 250 Rs. 1.25/ Unit > 250 Rs. 2.50/ Unit AnsImports system.console Module Module1 Sub Main() Dim a As Integer WriteLine("Enter the units ") a = Console.ReadLine() If a < 150 Then Console.WriteLine("no. charge") ElseIf a > 150 & a < 250 Then a = a * 1.25 WriteLine("Your Bill Is = {0}", a) Else a = a * 2.5 Console.WriteLine("Your bill is = {0}", a) End If ReadKey() End Sub End Module

Q 2. Design a window based application to calculate salary of an employee after reading basic_salary, HRA, DA and PF in textboxes. Make use of buttons, message boxes and validations wherever possible? Ans
Public Class Form1 Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim s, h, f, p As Integer s = TextBox1.Text MessageBox.Show("the salary is " & s) h = TextBox2.Text MessageBox.Show("The HRA is " & h) f = TextBox3.Text MessageBox.Show("The DA is " & f) p = TextBox4.Text MessageBox.Show("The PF is " & p) TextBox5.Text = Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox2.Text) + Convert.ToInt32(TextBox3.Text) + Convert.ToInt32(TextBox4.Text) MessageBox.Show("the total amount" & TextBox5.Text) End Sub End Class

Q 3. Develop a application to read a number from user between 1 to 5. Display the number in words and validate it like that if user enters zero it will ask the user whether he wants to continue or not? AnsImports system.console Module Module1 Sub Main() Dim n As Integer WriteLine("Enter the number: ") n = ReadLine() ReadKey() Select Case (n) Case 0 WriteLine("Do you want to continue or not......") ReadKey() Case 1 WriteLine("one") ReadKey() Case 2 WriteLine("two") ReadKey() Case 3 WriteLine("three") ReadKey() Case 4 WriteLine("four") ReadKey() Case 5 WriteLine("five") ReadKey() Case Else WriteLine("enter number 0 to 5") ReadKey() End Select End Sub End Module

PART B Q 1. Create an console based application in VB.Net to find the prime numbers between 80 and 60? AnsImports system.console Module Module1 Sub Main() Dim a, i As Integer WriteLine("Prime numbers between 80 and 60") For i = 0 To 80 If i >= 60 Then a = i Mod 2 If a = 0 Then Else WriteLine("{0}", i) End If End If Next ReadKey() End Sub End Module

Q 2. Create an console based application in VB.Net to find 2nd lowest and 2nd largest number in array of 5 elements? ANSImports system.console Module Module1 Sub Main() WriteLine("2nd largest and 2nd smallest number") Dim a(5) As Integer a(0) = 404 a(1) = 333 a(2) = 122 a(3) = 112 a(4) = 100 Dim i, j, temp As Integer For i = 0 To 5 Step +1 For j = 0 To i Step +1 If a(i) > a(j) Then temp = a(i) a(i) = a(j) a(j) = temp End If Next Next WriteLine("largest number is = {0}", a(0)) WriteLine("Smallest number is = {0}", a(4)) For i = 0 To 4 Step +1 WriteLine("{0}", a(i)) Next ReadKey() End Sub End Module

Q 3. Create an application form for online registration of patient with proper validations? AnsPrivate Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox7.Text = ""

End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If TextBox1.Text = "" Then MessageBox.Show("Enter correct the value") End If

If TextBox2.Text = "" Then MessageBox.Show("Enter correct the value")

End If If TextBox3.Text = "" Then MessageBox.Show("Enter correct the value") End If If TextBox4.Text = "" Then MessageBox.Show("Enter correct the value") End If If TextBox5.Text = "" Then MessageBox.Show("Enter correct the value") End If If TextBox6.Text = "" Then MessageBox.Show("Enter correct the value") End If If TextBox7.Text = "" Then MessageBox.Show("Enter correct the value") End If

End Sub End Class

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