Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# Pseudo code

Mary Moore
Greenhorn
Posts: 1
Please could someone translate this Java into Pseudo code for me? Thankyou,
Mary.

public class qu1
{
public static void main(String[] args)

{
String[] qu1array = {"Isabella Rossellina appeared in \u0027TOW Frank Jr.\u0027", "Elle Macpherson\u0027s character was \u0027Jill\u0027.", "Freddie Prinze Jr. appeared in \u0027TOW the Male Nanny\u0027.", "Bruce Willis played Rachel\u0027s father.", "Monica and Rachel were the only friends that didn\u0027t find Denise Richards attractive.", "Jennifer Saunders played Emily\u0027s mom, Anthea Wallam.", "Ralph Lauren and Charlton Heston both star as themselves during the series.", "Reese Witherspoon plays Rachel\u0027s sister Jill.", "Courtney Cox and Jennifer Aniston\u0027s husbands have both appeared in the series.", "Charlie Sheen was a fireman that went out with Pheobe."};
int[] a1array = {1,2,1,2,1,2,1,1,1,2};

// DECLARE QUESTION VARIABLES

// SET 10 QUESTIONS

for (int i=1; i<=10; i++)
{

q = (0 + (int)(10 * Math.random()));
System.out.println("Question" + i + ": \n" +qu1array[q]);

{
System.out.println("Well done");
else
System.out.println("You are wrong!");
}
}
}
}

Joel McNary
Bartender
Posts: 1840
In the pseudo-code known as English:
This code appears to pick a random statement from a statically defined array of questions (about pop-culture, it seems. They seem to be all questions releated to the TV show Friends. {I'm guessing. It could just as well be Seinfeld or any of a thousand other shows that I don't watch ) ). It then prompts the user for an answer to the statment. If the user got it right, then display "Well done," otherwise, display "You are wrong!". It does this ten times -- however, the questions may be repeated!

This appears to be a true-false quiz; however, some of the statements are contextless, and, while I recognize a few names, I don't know enough about any of them to be able to state which of the answers 1 and 2 is true and false.
[ January 19, 2005: Message edited by: Joel McNary ]

Layne Lund
Ranch Hand
Posts: 3061
Is this a homework assignment? I ask this because in practice, one typically writes pseudocode first and then translates it into actual code (whether in Java or some other language). Very rarely do you actually need to take code and translate it into pseudocode. Perhaps this is because the actual code can be treated as pseudocode as it is. This is useful if, for example, you want to translate from one programming language to another.

So I guess I will answer your question with a few questions of my own. First, what is the purpose of writing pseudocode to describe this program? Also have you made any attempt to do this on your own?

IMO, it is unfortunate that someone has already answered your question directly. I think it is a much better learning experience for you to try this on your own and ask specific questions about things you don't quite understand. For homework assignments, that is typically the point.

Layne