3. For the following problem, write the code that should go in each box next to
ID: 3587775 • Letter: 3
Question
3. For the following problem, write the code that should go in each box next to the box leter below (3 points each Universal Motors makes cars. They compute the purchase price of their autos by taking the base price of the vehicle, adding varlous costs for different options. The code below finds the added cost for diffierent engine cholces Sub ComputeEngineCost Dim strEngineChoice As String Dim strsiCylinder As String Dim strEightCylinder As String Dim strDiesel As String Dim curEngineCost As Currency strSnCylinder- "Enter S for a 6 cylinder engine strigheCylinder·tter E for an 8 Oliner engine." strDiesel "Enter D for a diesel engine. inputhonlstrSsahCylinder&vCrut;& strEightCylinder& vooL&strDiese; "ST Then curEngineCost 150 curEngineCost 475 curEngineCost 750 MsgBos Cvalid Selection 1 Exit Sub End if Mnghox (The selected engine will cot" & Format tnd SubExplanation / Answer
Sub ComputeEngineCost()
Dim strEngineChoice As String
Dim strSixCylinder As String
Dim strEightCylinder As String
Dim strDiesel As String
Dim curEngineCost As Currency
strSixCylinder = "Enter S for a 6 cylinder engine."
strEightCylinder = "Enter E for an 8 cylinder engine."
strDiesel = "Enter D for a diesel engine."
strEngineChoice = InputBox(strSixCylinder & vbCrLf & strEightCylinder & vbCrLf & strDiesel)
If strEngineChoice = "S" Then
curEngineCost = 150
ElseIf strEngineChoice = "E" Then
curEngineCost = 475
ElseIf strEngineChoice = "D" Then
curEngineCost = 750
Else
MsgBox("Invalid Selection")
Exit Sub
Exit If
MsgBox("The selected engine will cost "&Format(curEngineCost, "Currency")&".")
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.