Explore BrainMass

Explore BrainMass

    Help in solving problem in C programming

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Please keep the program in the orginal form. I am writing in C program using a C compiler.

    Need help at the end of the program. It needs a DO-WHILE statement at the end. Selecting Y should go to the main menu. Selecting N should print "The End".

    getch (); and return (0); must be at the end of my compiler to work.

    do{
    printf ("Would you like to convert another currency? Y or Nn")

    }while

    /*Currency conversion.*/

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <system.h>
    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 in USD that you would like to convert to foreign currency:n");
    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 USD is %.2f MXN 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 USD is %.2f JPY 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 USD is %.2f HKD 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 USD is %.2f KRW 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 USD is %.2f PHP 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");

    } /*end switch */

    getch ();
    return (0);

    }

    © BrainMass Inc. brainmass.com March 6, 2023, 12:48 pm ad1c9bdddf
    https://brainmass.com/computer-science/php/help-in-solving-problem-in-c-programming-20711
    $2.49

    ADVERTISEMENT