in BASIC language, i need to make function smallMiles(size) display the smallest
ID: 3787020 • Letter: I
Question
in BASIC language, i need to make function smallMiles(size) display the smallest number in the MilesDriven array . here is my code so far:
size =1
Dim Monthname$(size)
Dim MilesDriven(size)
do
print "Enter your choice from this menu."
print "Enter 'P' to enter miles and month,OR"
print "Enter 'S' to search for month. OR,"
print "Enter 'M to search month with smallest miles. OR,"
print "Enter 'L' to search for month with largest miles. OR,"
print "Enter 'E' to exit."
input choice$
select case (choice$)
case "P","p"
res= collectData(size)
case "S","s"
res = search(size)
case "M","m"
res = smallMiles(size)
case "L","l"
res = largeMiles(size)
case "E","e"
print "Have a nice day.Goodbye."
case else
print "Invalid choice, please try again"
print
end select
loop until (choice$ = "E" or choice$ = "e" )
function collectData(size)
for position= 0 to size
print "Enter miles."
input MilesDriven(position)
print "Enter month."
input Monthname$(position)
next
end function
function search(size)
print "Enter month."
input month$
for position = 0 to size
if(month$ = Monthname$(position))then
print "The month is: ";Monthname$(position)
print "The number of miles driven is: ";MilesDriven(position)
exit for
end if
next
end function
function smallMiles(size)
print "Enter month."
input month$
for position = 0 to size
smallest = MilesDriven(position)
if (month$ = Monthname$(position))then
if (MilesDriven(position) < smallest )then
smallest = MilesDriven(position)
end if
print "The month with smallest miles driven is: ";Monthname$(position)
print "The smallest miles driven is: ";smallest
exit for
end if
next
end function