Answer to Question #283487 in Visual Basic for Alvin

Question #283487

Develop a solution to compute the average price for three items’ price input by user one at a time. If the average price is greater than RM50, 10% discount will be given to the customer. Your program should be able to display the nett amount that needs to be paid by that customer.


1
Expert's answer
2021-12-29T07:57:32-0500
Imports System.IO


Module Module1
    Sub Main()
        Dim sumPrice As Double = 0


        For i As Integer = 0 To 2
            Console.Write("Enter the price for item {0}: ", (i + 1))
            Dim price As Double = Double.Parse(Console.ReadLine())
            sumPrice += price
        Next


        Dim averagePrice As Double = sumPrice / 3.0
        Dim discount As Double
        If averagePrice > 50 Then
            discount = sumPrice * 0.1
            Console.WriteLine("10% discount: {0}", discount)
        End If
        sumPrice -= discount
        Console.WriteLine("The nett amount: {0}", sumPrice)




        Console.ReadLine()
    End Sub




End Module

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS