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

Yogesh 17 Gadpracticaldone

The document contains code for two programming examples: 1) A class to calculate the volume of a box by passing length, breadth, and height values. 2) A class to calculate the average of values entered separated by commas by adding them to a list and dividing the total by the count.

Uploaded by

suya24telang
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)
19 views

Yogesh 17 Gadpracticaldone

The document contains code for two programming examples: 1) A class to calculate the volume of a box by passing length, breadth, and height values. 2) A class to calculate the average of values entered separated by commas by adding them to a list and dividing the total by the count.

Uploaded by

suya24telang
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/ 3

Gramin Technical and Management Campus

Department of computer engineering


Subject/code: -GAD/22034

Name:-suyash telang Batch:- B Roll no:- 41

DOP: DOS:-

1. Coding:-
PublicClassForm1
ClassBox
Public length AsDouble
Public breadth AsDouble
Public height AsDouble

PublicFunction Volume() AsDouble


Return length * breadth * height
EndFunction
EndClass

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs)


Handles Button1.Click
Dim myBox AsNewBox()

myBox.length = Double.Parse(InputBox("Enter the length of the box:", "Box Volume"))


myBox.breadth = Double.Parse(InputBox("Enter the breadth of the box:", "Box Volume"))
myBox.height = Double.Parse(InputBox("Enter the height of the box:", "Box Volume"))

Dim boxVolume AsDouble = myBox.Volume()

MsgBox("The volume of the box is "& boxVolume &" cubic units.",


MsgBoxStyle.Information, "Box Volume")

EndSub
EndClass
Output:-

2.Coding:-

PublicClassForm2
ClassComboAverage
Private values AsNewList(OfDouble)

PublicSub AddValue(ByVal value AsDouble)


values.Add(value)
EndSub

PublicFunction GetAverage() AsDouble


If values.Count = 0 Then
Return 0
Else
Dim total AsDouble = 0
ForEach value AsDoubleIn values
total += value
Next
Return total / values.Count
EndIf
EndFunction
EndClass

PrivateSub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVale


As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
EndSub

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs)


Handles Button1.Click
Dim comboAvg AsNewComboAverage()

Dim input AsString = InputBox("Enter values separated by commas:", "Combo Box


Average")
Dim values AsString() = input.Split(",")
ForEach value AsStringIn values
comboAvg.AddValue(Double.Parse(value))
Next

Dim avg AsDouble = comboAvg.GetAverage()

MsgBox("The average of the values is "& avg, MsgBoxStyle.Information, "Combo Box


Average")

EndSub
EndClass

Output:-

You might also like