We help IT Professionals succeed at work.

Foriegn currency to another foriegn currency exchange calculation issue

Cabochick05
Cabochick05 asked
on
385 Views
Last Modified: 2011-09-20
Hi all,
I cannot get my foreign currency to exhange to another foreign currency.  We are supposed to use two switch cases statements. We were advised to use a formula that takes the 1st foreign currency to USD and then to another foriegn currency which will allow the exchange from one FC to FC. Here is what I have so far.  I've racked my brain on this all week and it's due tomorrow at 6p mst.  Nothing like waiting until the last minute!  Any help would be appreciated!  I just need to keep it simple! Thanks so much!
Susan =)

/*6/19/06 POS370 Susan Johnson Individual Assignment 3 of 3:
* Week 1 - Find 5 foreign currencies and display conversion in us dollars
* Week 2 - Offer the user a choice of which foreign currency and how much to exchange into USD
* Week 3 - Change any currency to any currency. Use two case statements one is from foriegn currency to USD.*/

#include <stdio.h>

main ()
{
float peso = 0.0885426;
float yen = 0.00895015;
float pound = 1.8775;
float can = 0.910415;
float ruble = 0.0374186;
float amt = 0.0;
float usd = 0.0;
float total = 0.0;
int choice1;
int choice2;
int promptUSD;
int promptXFC;
int x = 0;

      printf("\nForiegn Currency Conversion Table\n");
      printf("\n\t1: Mexican peso");
      printf("\n\t2: Japanese yen");
      printf("\n\t3: British pound");
      printf("\n\t4: Canadian dollar");
      printf("\n\t5: Russian ruble");

   while (x == 0)
   {/*begin while loop*/
      printf( "\n\nChoose a foreign currency using 1 - 5: ");
      scanf ( "%d", &choice1);
      
      if (choice1 >= 1 && choice1 <= 5)
      {/*begin if statement*/
            printf( "\n\nEnter the amount to be converted: ");
               scanf( "%f", &amt);
      
            switch (choice1)
                  {/*begin switch/case*/      
        
                    case 1:
                             usd = peso*amt;
                             break;
                     case 2:
                              usd = yen*amt;
                              break;
                     case 3:
                              usd = pound*amt;
                              break;
                     case 4:
                              usd = can*amt;
                                    break;
                     case 5:
                              usd = ruble*amt;
                              break;  
               default:
                        printf("\nYou did not choose a valid currency 1 -5:\n");
                  
          
      }/* end if*/
      
      }/* end switch/case*/
      
      printf( "\n\nUse 1 - 5 again to exchange your amount to another currency: ");
      scanf ( "%d", &choice2);
      
            switch (choice2)
                  {/*begin switch/case*/      
        
                    case 1:
                             usd=amt/peso;
                             printf("\n\nYou entered $%.2f which equals $%.2f pesos\n",amt,usd);
                             break;
                     case 2:
                              usd = amt/yen;
                              printf("\n\nYou entered $%.2f which equals $%.2f Yen\n", amt,usd);
                              break;
                     case 3:
                              total = pound*amt;
                              printf("\n\nYou entered $%.2f which equals $%.2f Pounds\n", amt,usd);
                              break;
                     case 4:
                              total = can*amt;
                              printf("\n\nYou entered $%.2f which equals $%.2f CAD\n", amt,usd);
                              break;
                     case 5:
                              total = ruble*amt;
                              printf("\n\nYou entered $%.2f which equals $%.2f rubles\n", amt,usd);
                              break;  
                     default:
                              printf("\nYou did not choose a valid currency 1 - 5:\n");
          
                  
            }/*end switch/case*/
            
      
      
      printf("\n\nWould you like to exchange your amount to another currency? 1 for yes, 2 for no: ");
      scanf("%d", &promptUSD);

            if (promptUSD == 2)
                  {/*begin if statement*/
                   x=1;
                    }/*end if statement*/      
 }/*end while loop*/      
                   printf("\n\nHave a nice day!");

             
        
   //else }
 
   //       printf("you entered and incorrect number, please choose from 1-5");

getchar();

}/*end main program*/
Comment
Watch Question

fridomCEO/Programmer
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.