# Currency Conversion Table- Pounds to Dollars

• 09-23-2009
phillysbest29
Currency Conversion Table- Pounds to Dollars
I have a programming assignment, and I am really struggling with it. I am supposed to produce a conversion table, that converts British pounds to US dollars. The program should first allow the user to enter an exchange rate. Then the program should print conversions for amounts beginning with one pound, in .25 increments, for amounts less than twenty pounds. Formatting should be the same as the sample output shown:

Enter exchange rate (GBP/USD): 1.6471
P 1.00 = \$ 1.65 P 1.25 = \$ 2.06 P 1.50 = \$ 2.47 P 1.75 = \$ 2.88
P 2.00 = \$ 3.29 P 2.25 = \$ 3.71 P 2.50 = \$ 4.12 P 2.75 = \$ 4.53
P 3.00 = \$ 4.94 P 3.25 = \$ 5.35 P 3.50 = \$ 5.76 P 3.75 = \$ 6.18
P 4.00 = \$ 6.59 P 4.25 = \$ 7.00 P 4.50 = \$ 7.41 P 4.75 = \$ 7.82
P 5.00 = \$ 8.24 P 5.25 = \$ 8.65 P 5.50 = \$ 9.06 P 5.75 = \$ 9.47
P 6.00 = \$ 9.88 P 6.25 = \$10.29 P 6.50 = \$10.71 P 6.75 = \$11.12
P 7.00 = \$11.53 P 7.25 = \$11.94 P 7.50 = \$12.35 P 7.75 = \$12.77
P 8.00 = \$13.18 P 8.25 = \$13.59 P 8.50 = \$14.00 P 8.75 = \$14.41
P 9.00 = \$14.82 P 9.25 = \$15.24 P 9.50 = \$15.65 P 9.75 = \$16.06
P10.00 = \$16.47 P10.25 = \$16.88 P10.50 = \$17.29 P10.75 = \$17.71
P11.00 = \$18.12 P11.25 = \$18.53 P11.50 = \$18.94 P11.75 = \$19.35
P12.00 = \$19.77 P12.25 = \$20.18 P12.50 = \$20.59 P12.75 = \$21.00
P13.00 = \$21.41 P13.25 = \$21.82 P13.50 = \$22.24 P13.75 = \$22.65
P14.00 = \$23.06 P14.25 = \$23.47 P14.50 = \$23.88 P14.75 = \$24.29
P15.00 = \$24.71 P15.25 = \$25.12 P15.50 = \$25.53 P15.75 = \$25.94
P16.00 = \$26.35 P16.25 = \$26.77 P16.50 = \$27.18 P16.75 = \$27.59
P17.00 = \$28.00 P17.25 = \$28.41 P17.50 = \$28.82 P17.75 = \$29.24
P18.00 = \$29.65 P18.25 = \$30.06 P18.50 = \$30.47 P18.75 = \$30.88
P19.00 = \$31.29 P19.25 = \$31.71 P19.50 = \$32.12 P19.75 = \$32.53 [/B]

I must use a double and int. Also, I must have 2 nested loops involved.

So far I have:

#include <stdio.h>

int main (void)

char Dollars;
char Pounds;

printf ("Enter Exhange Rate (GPS/USD): %d/n");

This is where I got lost, in relation to nested loops and such. Someone's help would be deeply appreciated.
• 09-23-2009
Obelisk
Quote:

Originally Posted by phillysbest29
I have a programming assignment, and I am really struggling with it. I am supposed to produce a conversion table, that converts British pounds to US dollars. The program should first allow the user to enter an exchange rate. Then the program should print conversions for amounts beginning with one pound, in .25 increments, for amounts less than twenty pounds. Formatting should be the same as the sample output shown:

Enter exchange rate (GBP/USD): 1.6471
P 1.00 = \$ 1.65 P 1.25 = \$ 2.06 P 1.50 = \$ 2.47 P 1.75 = \$ 2.88
P 2.00 = \$ 3.29 P 2.25 = \$ 3.71 P 2.50 = \$ 4.12 P 2.75 = \$ 4.53
P 3.00 = \$ 4.94 P 3.25 = \$ 5.35 P 3.50 = \$ 5.76 P 3.75 = \$ 6.18
P 4.00 = \$ 6.59 P 4.25 = \$ 7.00 P 4.50 = \$ 7.41 P 4.75 = \$ 7.82
P 5.00 = \$ 8.24 P 5.25 = \$ 8.65 P 5.50 = \$ 9.06 P 5.75 = \$ 9.47
P 6.00 = \$ 9.88 P 6.25 = \$10.29 P 6.50 = \$10.71 P 6.75 = \$11.12
P 7.00 = \$11.53 P 7.25 = \$11.94 P 7.50 = \$12.35 P 7.75 = \$12.77
P 8.00 = \$13.18 P 8.25 = \$13.59 P 8.50 = \$14.00 P 8.75 = \$14.41
P 9.00 = \$14.82 P 9.25 = \$15.24 P 9.50 = \$15.65 P 9.75 = \$16.06
P10.00 = \$16.47 P10.25 = \$16.88 P10.50 = \$17.29 P10.75 = \$17.71
P11.00 = \$18.12 P11.25 = \$18.53 P11.50 = \$18.94 P11.75 = \$19.35
P12.00 = \$19.77 P12.25 = \$20.18 P12.50 = \$20.59 P12.75 = \$21.00
P13.00 = \$21.41 P13.25 = \$21.82 P13.50 = \$22.24 P13.75 = \$22.65
P14.00 = \$23.06 P14.25 = \$23.47 P14.50 = \$23.88 P14.75 = \$24.29
P15.00 = \$24.71 P15.25 = \$25.12 P15.50 = \$25.53 P15.75 = \$25.94
P16.00 = \$26.35 P16.25 = \$26.77 P16.50 = \$27.18 P16.75 = \$27.59
P17.00 = \$28.00 P17.25 = \$28.41 P17.50 = \$28.82 P17.75 = \$29.24
P18.00 = \$29.65 P18.25 = \$30.06 P18.50 = \$30.47 P18.75 = \$30.88
P19.00 = \$31.29 P19.25 = \$31.71 P19.50 = \$32.12 P19.75 = \$32.53 [/B]

I must use a double and int. Also, I must have 2 nested loops involved.

So far I have:

This is where I got lost, in relation to nested loops and such. Someone's help would be deeply appreciated.

try making a psuedo code of what you are try to achieve and whats ur procedure

Quote:

#include <stdio.h>

int main (void)

char Dollars;
char Pounds;

printf ("Enter Exhange Rate (GPS/USD): %d/n");

this is a start...but you need to make a method that converts the currency ...so use mathemetical forumlae using the current conversion rate.

printf ("Enter Exhange Rate (GPS/USD): %d/n");

use scanf to read the input and store it a variable...
and use that variable in your "Conversion"
• 09-23-2009
phillysbest29
ok can you show me an example of a for loop with the converter in it?
• 09-23-2009
```int i;   get your rate (maybe with scanf();) pounds = 1; while(pounds <= 25) {   printf("\n");   for(i = 0; i < 4; i++) {       //adjust your before and after the decimal print field widths, here       printf("P %2.2lf = \$ %3.2lf ", pounds, pounds * rate);       increment pounds here   }  }```