Computer Science Homework Solutions
Problem
#20697

Help in debugging C program

I have a couple of problems with this program.

First: I need help in changing my conversion program. I need to convert U.S dollars to foreign currency vice converting foreign currency to U.S. dollars. My switch statements work.

Second: My program DO WHILE LOOP does not work. After the program changes the currency, I should be able to end the program or go back to the main menu to convert another currency.

/*Currency conversion.*/

#include
#include
#include
#include
main ()
{
/* Data Declaration statements*/

int Curr_type;
float For_curr;
float Equ_curr;
int choice;

printf("CURRENCY CONVERTERn");
printf("Choose currency optionn");
printf("Press 1 for MXN: Mexican Peson");
printf("Press 2 for JPY: Japanese Yenn");
printf("Press 3 for HKD: Hong Kong Dollarsn");
printf("Press 4 for KRW: Korean Wonn");
printf("Press 5 for PHP: Philippine Peson");
printf("Enter the type of currency:");
scanf("%d", &Curr_type);/* & symbol assigns L-H and R-H to the left hand quantity*/
printf("Enter the amount of money that you would like to convert to USD:");
scanf("%f", &For_curr);

/* Switch statement to Case Curr_type (1, 2, 3, 4, 5)*/
switch(Curr_type)
{

/* MXN: Mexican Peso */
case 1:
Equ_curr = ((For_curr) * (0.08764));
printf ("The equivalent of %.2f MXN is %.2f USD n", For_curr, Equ_curr);
break; /* Jump to end of switch*/

/* JPY: Japanese Yen */
case 2:
Equ_curr = ((For_curr) * (0.009093));
printf ("The equivalent of %.2f JPY is %.2f USD n", For_curr, Equ_curr);
break; /* Jump to end of switch*/

/* HKD: Hong Kong Dollars */
case 3:
Equ_curr = ((For_curr) * (0.1283));
printf ("The equivalent of %.2f HKD is %.2f USD n", For_curr, Equ_curr);
break; /* Jump to end of switch*/

/* KRW: Korean Won */
case 4:
Equ_curr = ((For_curr) * (0.0008591));
printf ("The equivalent of %.2f KRW is %.2f USD n", For_curr, Equ_curr);
break; /* Jump to end of switch*/

/* PHP: Philippine Peso */
case 5:
Equ_curr = ((For_curr) * (0.01791));
printf ("The equivalent of %.2f PHP is %.2f USD n", For_curr, Equ_curr);
break; /* Jump to end of switch*/

/*Other: Currency of any other country */
default:
printf("We are sorry, this system doesn't support conversion for this currencyn");
break;

} /*end switch */


do
{
printf ("Would you like to convert another currency? Y or N");
scanf("%c", &choice);

}
while
((choice 1 = 'N'));
getch ();
return (0);
printf ("the end");

((choice 2 = 'Y'));
//*I would like the main menu to return*//


}

Solution
What is this?
By OTA - Overall OTA Rating
Purchase Cost Now
$2.19 CAD (was ~$19.95)
Included in Download
  • Plain text response
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
Browse