Programming question ( Examination type):
The cost of delivery is calculated as follows:
● There is a basic delivery charge of $5 for all orders.
● If the total weight of an order is more than 1 kg, there is an additional charge of $0.50 or every extra 0.1 kg.
● If the total volume of an order is more than 1000 cubic.cm, there is an additional charge of $0.50 for every extra 200 cubic.cm
Write a program to ask user total weight and total volume of the items , and then show the total cost of delivery.
Module Module1
Sub Main()
Dim Totalweight, Totalvolume, Extravolume As Decimal
Dim costweight, costvolume, totalcost As Decimal
Console.Write("Enter total weight in kg:")
Totalweight = Console.ReadLine()
Console.Write("Enter it volume in cubic.cm :")
Totalvolume = Console.ReadLine()
If Totalweight > 1 Then
costweight = ((Totalweight - 1) / 0.1) * 0.5 + 5
ElseIf Totalweight > 0 And Totalweight <= 1 Then
costweight = 5
Else
costweight = 0
End If
If Totalvolume > 1200 Then
Extravolume = (Totalvolume - 1000)
If (Extravolume / 200) > 0 Then
If (Extravolume / 200) Mod 200 = 1 Then
costvolume = ((Extravolume / 200) * 0.5) + 5
Else
costvolume = (((Extravolume \ 200) + 1) * 0.5) + 5
End If
End If
ElseIf Totalvolume > 0 And Totalvolume < 1200 Then
costvolume = 5
Else
costvolume = 0
End If
If costweight > 1 And costvolume > 1 Then
totalcost = costweight + costvolume - 5
Else
totalcost = 0
End If
Console.WriteLine("The cost of delivery=" & totalcost & "$")Console.ReadLine()
End Sub
End Module
Instagram
The cost of delivery is calculated as follows:
● There is a basic delivery charge of $5 for all orders.
● If the total weight of an order is more than 1 kg, there is an additional charge of $0.50 or every extra 0.1 kg.
● If the total volume of an order is more than 1000 cubic.cm, there is an additional charge of $0.50 for every extra 200 cubic.cm
Write a program to ask user total weight and total volume of the items , and then show the total cost of delivery.
Module Module1
Sub Main()
Dim Totalweight, Totalvolume, Extravolume As Decimal
Dim costweight, costvolume, totalcost As Decimal
Console.Write("Enter total weight in kg:")
Totalweight = Console.ReadLine()
Console.Write("Enter it volume in cubic.cm :")
Totalvolume = Console.ReadLine()
If Totalweight > 1 Then
costweight = ((Totalweight - 1) / 0.1) * 0.5 + 5
ElseIf Totalweight > 0 And Totalweight <= 1 Then
costweight = 5
Else
costweight = 0
End If
If Totalvolume > 1200 Then
Extravolume = (Totalvolume - 1000)
If (Extravolume / 200) > 0 Then
If (Extravolume / 200) Mod 200 = 1 Then
costvolume = ((Extravolume / 200) * 0.5) + 5
Else
costvolume = (((Extravolume \ 200) + 1) * 0.5) + 5
End If
End If
ElseIf Totalvolume > 0 And Totalvolume < 1200 Then
costvolume = 5
Else
costvolume = 0
End If
If costweight > 1 And costvolume > 1 Then
totalcost = costweight + costvolume - 5
Else
totalcost = 0
End If
Console.WriteLine("The cost of delivery=" & totalcost & "$")Console.ReadLine()
End Sub
End Module