Soal 1 :
Ada 2 parameter (x,y), hitung angka
ganjil dari Ganjil (X,Y), contoh :
Ganjil(2,10) ->
hasil : 3 5 7 9
Ganjil(10,5) ->
hasil : ERROR
Buatlah Flowchart Algoritma dan Program VBScript HTML
FLOWCHART
PROGRAM VBScript HTML
<html>
<head>
<script language="VBS">
function ganjil(a,b)
dim hitung
hitung = ""
for p=a to b
if p mod 2 = 1 then
hitung = hitung & " " & p
end if
next
ganjil = hitung
end function
</script>
</head>
<body>
<script language="VBS">
x=cint(inputbox("masukkan X"))
y=cint(inputbox("masukkan Y"))
If x<y then
hasil = ganjil(x,y)
else
hasil = "ERROR"
end if
document.write hasil
</script>
</body>
</html>
Soal 2 :
Ada 4 parameter (a,b,c,d), hitung
pekalian dari Perkalian(a,b,c,d) = Carimax(a,b,c,d) * Carimin(a,b,c,d), contoh
:
Carimax(4,5,6,7) -> hasil : 7
Carimin(4,5,6,7) -> hasil : 4
Perkalian(4,5,6,7) -> hasil : 7 * 4 = 28
Buatlah Flowchart Algoritma dan Program VBScript HTML
FLOWCHART
PROGRAM VBScript HTML
<html>
<head>
<script language="VBS">
function carimax(h,i,j,k)
dim hitung
dim ab
dim abc
dim abcd
if h>i then
ab = h
else
ab = i
end if
if ab>j then
abc = ab
else
abc = j
end if
if abc>k then
abcd = abc
else
abcd = k
end if
hitung = abcd
carimax = hitung
end function
</script>
<script language="VBS">
function carimin(h,i,j,k)
dim hitung
dim ab
dim abc
dim abcd
if h<i then
ab = h
else
ab = i
end if
if ab<j then
abc = ab
else
abc = j
end if
if abc<k then
abcd = abc
else
abcd = k
end if
hitung = abcd
carimin = hitung
end function
</script>
<script language="VBS">
function perkalian(p,q,r,s)
dim hitung
hitung = carimax(p,q,r,s)*carimin(p,q,r,s)
perkalian = hitung
end function
</script>
</head>
<body>
<script language="VBS">
a=cint(inputbox("masukkan A"))
b=cint(inputbox("masukkan B"))
c=cint(inputbox("masukkan C"))
d=cint(inputbox("masukkan D"))
nilmin = carimin(a,b,c,d)
nilmax = carimax(a,b,c,d)
hasil = perkalian(a,b,c,d)
document.write "Nilai Min = " & nilmin & "</br>"
document.write "Nilai Max = " & nilmax & "</br>"
document.write "Hasil perkalian = " & hasil
</script>
</body>
</html>