1. ## Pseudocode help!!!

Hi, I have an assignment to do and my Pseudocode has to be in by tomorrow (its currently 10.30pm in Ireland). The assignment is described here:
http://www.comp.dit.ie/mcollins/ft22...signment1.html

I just want to know if I'm doing my Pseudocode correctly. Am I supposed to put things like:
pound = 0.70 * amount

in my pseudocode?

Anyway here is the first 3 cases so you can tell me if its OK.

Code:
```BEGIN
DO
INPUT country
SWITCH country

CASE 1
DISPLAY coversion options
INPUT option
IF option is 1
prompt for amount
INPUT amount
convert currency
DISPLAY converted currency
ELSE IF option is 2
prompt for amount
INPUT amount
convert currency
DISPLAY converted currency
ELSE
DISPLAY error message
BREAK

CASE 2
DISPLAY coversion options
INPUT option
IF option is 1
prompt for amount
INPUT amount
convert currency
DISPLAY converted currency
ELSE IF option is 2
prompt for amount
INPUT amount
convert currency
DISPLAY converted currency
ELSE
DISPLAY error message
BREAK

CASE 3
DISPLAY coversion options
INPUT option
IF option is 1
prompt for amount
INPUT amount
convert currency
DISPLAY converted currency
ELSE IF option is 2
prompt for amount
INPUT amount
convert currency
DISPLAY converted currency
ELSE
DISPLAY error message```
I'd really appreciate any help to save me staying up all night.

2. Hello,

Don't flag your question as "Urgent", even if it is for you. Claiming urgency is very likely to be counter-productive.

All in all, your first three cases seem fine. I'm not sure where the DO stops, guessing it will be a DO-WHILE loop. Plus your BEGIN does not END, or third CASE does not BREAK, though I'm guessing it wasn't stated also.

- Stack Overflow

3. Nice of you to leave it to the last minute though....

So what exactly is the difference between case 1 and case 2 ?
Looks a lot like it needs to be a function with a parameter or two.

4. Originally Posted by Stack Overflow
Don't flag your question as "Urgent", even if it is for you. Claiming urgency is very likely to be counter-productive.
Edited.

All in all, your first three cases seem fine. I'm not sure where the DO stops, guessing it will be a DO-WHILE loop. Plus your BEGIN does not END, or third CASE does not BREAK, though I'm guessing it wasn't stated also.
I only pasted a section of the pseudocode which is why there is no end.

So what exactly is the difference between case 1 and case 2 ?
Thats one of the main questions I need answered. Is it OK for the first 3 cases to be identical or should I add something to change it? Case 1 is Britain (pound), case 2 is Denmark (Krone) and case 3 is Japan (Yen).

The only thing in the code that would make case 1 different to case 2 is the wording inside the printf tags aswell as the line: "pound = 0.70 * amount" would be changed to convert from Krone to Euro and vice versa.

5. Thats one of the main questions I need answered. Is it OK for the first 3 cases to be identical or should I add something to change it? Case 1 is Britain (pound), case 2 is Denmark (Krone) and case 3 is Japan (Yen).
Of course it's not okay. use something like

Code:
`CASE POUND`
Remember however, that there are no hard and fast rules for pseudo-code. The purpose of it is like sketching before painting a mural. You want to know exactly what you have where, how it's organized, and how you're going to go about painting the whole thing. It is through this that you can derive some rules requiring clarification, such as in your switch / case.

6. So would the following be OK (changes in bold):
Code:
```CASE POUND
DISPLAY coversion options
INPUT option
IF option is euro to pound
prompt for amount
INPUT amount
convert currency
DISPLAY converted currency
[/b]ELSE IF option is pound to euro[/b]
prompt for amount
INPUT amount
convert currency
DISPLAY converted currency
ELSE
DISPLAY error message
BREAK```
Also, one question that hasn't been answered. Should I write something like the following (instead of "convert currency"):

Code:
```prompt for amount
INPUT amount
pound = 0.70 * amount
DISPLAY converted currency```
Thanks again.

7. The changes do look good.

Especially now that you define what each case does.

Should I write something like the following (instead of "convert currency"):
» Since you did modify some of the statements in your pseudocode, it may actually be good to write the conversion process instead of "convert currency".

Code:
```prompt for amount
INPUT amount
pound = 0.70 * amount
DISPLAY converted currency```
» Something like this looks fine. It will help define which case does what with which currency, if that makes sense.

- Stack Overflow

8. Ok, thanks a lot. I'll check this topic in the morning for replies so if anyone has anything to add please do.

9. I always prefer to write my programs as scalable as possible. Something like:
Code:
```#include <stdio.h>
#include <stdlib.h>

struct
{
char *name;            // Name of currency
float convert_factor;  // Percent of dollar worth
} moneys[] =
{
{ "dollar", 1.00f },
{ "zoola",  0.32f },
{ "barwi",  1.94f },
{ "warmo",  0.86f },
{ NULL }
};

int main(void)
{
int choice, from, to;
float amount;
char buf[50];

do
{
puts("Convert money from:");
for(from = 0;moneys[from].name;from++)
printf("\t%d) %s\n", from+1, moneys[from].name);
printf("Which one (1-%d)? ", from);
fflush(stdout);
fgets(buf, sizeof(buf), stdin);
choice = atoi(buf);
} while(choice < 1 || choice > from);

from = choice-1;

do
{
puts("Convert money to:");
for(to = 0;moneys[to].name;to++)
if(to != from)
printf("\t%d) %s\n", to+1, moneys[to].name);
printf("Which one (%d-%d)? ", from == 0?2:1, (to == from+1)?to-1:to);
fflush(stdout);
fgets(buf, sizeof(buf), stdin);
choice = atoi(buf);
} while(choice < 1 || choice > to || choice == from+1);

to = choice-1;

printf("Amount? ");
fflush(stdout);
fgets(buf, sizeof(buf), stdin);
amount = atof(buf);

printf("%s: %f\n", moneys[from].name, amount);
amount /= moneys[from].convert_factor;
amount *= moneys[to].convert_factor;
printf("%s: %f\n", moneys[to].name, amount);

return 0;
}```
To add another type of currency it's a matter of adding 1 simple line to the program.

10. Originally Posted by itsme86
I always prefer to write my programs as scalable as possible.
Me too.

11. Originally Posted by Dave_Sinkula