.NET Practical Slip 19 Q B

2. Slip-1 Problem Statement

Q. Write a C#.Net program to accept and display ‘n’ customer’s details such as customer_no, Name, address, item_no, quantity, and price. Display the total price of all items. 25 Marks

Answer:

Public Class Form1
    Dim goodVotes As Integer = 0
    Dim satisfactoryVotes As Integer = 0
    Dim badVotes As Integer = 0
    Dim totalVotes As Integer = 0

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If RadioButton1.Checked Then
            goodVotes += 1
        ElseIf RadioButton2.Checked Then
            satisfactoryVotes += 1
        ElseIf RadioButton3.Checked Then
            badVotes += 1
        End If

        totalVotes += 1

        Dim goodPercentage As Double = 0
        Dim satisfactoryPercentage As Double = 0
        Dim badPercentage As Double = 0

        If totalVotes > 0 Then
            goodPercentage = (goodVotes / totalVotes) * 100
            satisfactoryPercentage = (satisfactoryVotes / totalVotes) * 100
            badPercentage = (badVotes / totalVotes) * 100
        End If

        Label1.Text = "Good: " & goodPercentage.ToString("F2") & "%"
        Label2.Text = "Satisfactory: " & satisfactoryPercentage.ToString("F2") & "%"
        Label3.Text = "Bad: " & badPercentage.ToString("F2") & "%"

        RadioButton1.Checked = False
        RadioButton2.Checked = False
        RadioButton3.Checked = False
    End Sub
End Class
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top