Hi, I\'m trying to figure out a way to go about getting this program done. The i
ID: 646393 • Letter: H
Question
Hi, I'm trying to figure out a way to go about getting this program done. The instructions below are all I have to go on, but I'm really at a loss. Thanks!
-------------------------------------------------------------------------------
The local Monster shelter has a coding system for creatures. Mr. Shepherd the office manager has some people that never can remember what creatures the codes represent. You state by using parallel single-dimension arrays you will create a listbox that when the employee clicks on an animal type, the coding number will appear in a label. (NOTE: Only single dimension parallel arrays may be used for this exercise - yes I know you could use a two-dimensional array, but not this week). Hint: Listboxes have an event called .SelectedIndex
Animals=Codes
Blood Donors = 100
Shape Shifter= 200
Ghost = 300
Witch = 400
Warlock = 500
Chimaera = 600
Zombie = 700
Japanese (Godzilla, Mothra, Gamera) =800
Vampires=900
Explanation / Answer
In Asp.net it can be written as
<script runat="server">
Sub submit(Sender As Object,e As EventArgs)
mess.Text="You selected " & drop1.SelectedItem.Text
End Sub
</script>
<!DOCTYPE html>
<html>
<body>
<form runat="server">
<asp:ListBox id="drop1" rows="3" runat="server">
<asp:ListItem selected="true">Blood Donors 100</asp:ListItem>
<asp:ListItem>Shape shifter 200</asp:ListItem>
<asp:ListItem>Ghost 300</asp:ListItem>
<asp:ListItem>Witch 400</asp:ListItem>
<asp:ListItem>Warlock 500</asp:ListItem>
<asp:ListItem>Chimaera 600</asp:ListItem>
<asp:ListItem>Zombie 700</asp:ListItem>
<asp:ListItem>Japanese 800</asp:ListItem>
<asp:ListItem>Vampires 900</asp:ListItem>
</asp:ListBox>
<asp:Button Text="Submit" runat="server" />
<p><asp:label id="mess" runat="server" /></p>
</form>
</body>
</html>
-------------------------------------------------------------------------------------------------------------------------
Parallel array declaration in c
char Animals[] = { "Blood Donors", "Shape Shifter", "Ghost", "Witch", "Warlock", "Chimaera" , "Zombie" , "Japanese", "Vampire"};
int codes [ ] = { 100,200,300,400,500,600,700,800,900 };
for (i=1; i<=9; i++)
printf("Animals %s,code: %d " ,Animal[i],codes[i]);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.