Help with writing some psuedocode?

Please just read this really quick and give me the start of it. I have the declarations and menu, but I don’t know what else to write.
………………………
1. Programming a Robot Battlebot
Write a program for a Robot Battlebot that satisfies these conditions:
? The battlebot should have the following command menu selections: Fire a Weapon, Move Forward, Move Backward, Exit
? If the Fire Weapon command is given, the user should be prompted to enter how far away (in feet) the opponent battlebot is. If the opponent is within 20 feet, a message should be displayed that the opponent is destroyed; if it is within 40 feet, the message should say it is partially disabled; and if it is over 40 feet away, the message should say it is unharmed. The battlebot has enough ammunition to fire its weapon five times in total. If it is out of ammunition, it should display a message that it cannot fire anymore when the Fire Weapon command is given.

a. Programming a Robot Battlebot
ammunition = 5 (initially)
fuel = 200 (initially)

a. Programming a Robot Battlebot
//main selection menu
//display menu
Display “Menu Selections:”
Display “1 –Fire Weapon”
Display “2 –Move Forward”
Display “3 –Move Backward”
Display “4 -Exit”
Display “Enter your selection: ”
Input choice

……………………………

I have the menu but don’t know what do write…

If choice == 1 then….
else.. if choice == 2 then…???

Please help.
I have never done something like this before and we started to do VB and I forgot writing psuedocode. I don’t understand why a while loop is necessary.

Sure, that approach should work.

Umm… But you probably need a while loop and a few other things in here. Also, the way you’ve explained how this is supposed to work is slightly nonsensical. Is this supposed to be translated to actual program code, or what? Whipping this up in Python should be the work of a few minutes.

EDIT:
*Sigh* You need a while loop in order to reprint the menu – otherwise it’ll just run once. How about something like this (you didn’t include anything about fuel either):

# Initialize
ammo = 5
fuel = 200
Choice = "0"

While Choice not "4" do:
Menu

# Menu
Method: Menu
print "Menu selection"
print "1 – Fire Weapon"
print "2 – Move Forward"
print "3 – Move Backward"
print "4 – Exit"
input Choice
if Choice == "1" Fire
if Choice == "2" Forward
if Choice == "3" Backward
End Method

# Fire Weapon
Method: Fire
if ammo > 0 print "How far away is the opponent?", input Distance
if ammo > 0 and (Distance > 0 and Distance <= 20) print "Opponent destroyed"
if ammo == 0 print "Cannot fire; out of ammo"
if ammo > 0 ammo–
End Method

# Move Forward
Method: Forward
print "Moving forward…"
End Method

# Move Backward
Method: Backward
print "Moving backward…"
End Method

Related Reading:

Uncategorized

Be Sociable, Share!

One thought on “Help with writing some psuedocode?

  1. Sure, that approach should work.

    Umm… But you probably need a while loop and a few other things in here. Also, the way you’ve explained how this is supposed to work is slightly nonsensical. Is this supposed to be translated to actual program code, or what? Whipping this up in Python should be the work of a few minutes.

    EDIT:
    *Sigh* You need a while loop in order to reprint the menu – otherwise it’ll just run once. How about something like this (you didn’t include anything about fuel either):

    # Initialize
    ammo = 5
    fuel = 200
    Choice = "0"

    While Choice not "4" do:
    Menu

    # Menu
    Method: Menu
    print "Menu selection"
    print "1 – Fire Weapon"
    print "2 – Move Forward"
    print "3 – Move Backward"
    print "4 – Exit"
    input Choice
    if Choice == "1" Fire
    if Choice == "2" Forward
    if Choice == "3" Backward
    End Method

    # Fire Weapon
    Method: Fire
    if ammo > 0 print "How far away is the opponent?", input Distance
    if ammo > 0 and (Distance > 0 and Distance <= 20) print "Opponent destroyed"
    if ammo == 0 print "Cannot fire; out of ammo"
    if ammo > 0 ammo–
    End Method

    # Move Forward
    Method: Forward
    print "Moving forward…"
    End Method

    # Move Backward
    Method: Backward
    print "Moving backward…"
    End Method
    References :

Leave a Reply