Help on C programming with a program that converts Uganda shillings to foreign curren

Discussion in 'Computer Science & Culture' started by jdibya, Nov 3, 2006.

Thread Status:
Not open for further replies.
  1. jdibya Registered Member

    Messages:
    1
    Please assist me with this assignment, am new to C programming

    A C program that can convert Uganda shillings to dollars, rands, euros, and pound sterlings when entering the Uganda Shillings at the key board

    1 dollar=1850 shillings, 1 euro=2880 shillings, 1 pound sterling = 3280 shillings, 1 Rand = 200 shillings

    This what I have tried but it has 1 error that there is a mising statement.

    *A program that uses functions to convert currency valves enter from the
    keyboard in Ug_shillings into foreign currency*/
    #include<stdio.h>
    #include<conio.h>

    float US_dollars,SA_rands,euros,pound_sterlings;
    float US_dollar=1850;
    float SA_rand=200;
    float euro=2280;
    float pound_sterling=3390;
    int Ug_shillings;
    float answer;
    main()

    {

    /*Input amount in Ug_shillings to be converted*/

    printf("input amount to be coverted in Ug_shillings\n:");
    scanf("%d",&Ug_shillings);

    /*Convert amount in Ug-shinnings to dollars*/

    US_dollar=1850
    US_dollars=Ug_shillings/1850
    {
    printf("%d/%d=%f\n",Ug_shillings,US_dollar,US_dollars);
    Answer=float US_dollars(US_dollars);
    }

    /*Convert amount in Ug-shilling to SA_rands*/
    SA_rand=200
    SA_rands=Ug_shillings/200

    {
    printf("%d/%d=%f\n",Ug_shillings,SA_rand,SA_rands);
    answer=float SA_rands(SA_rands);
    }

    /*Convert amount in Ug_shillings to euro*/
    euro=2280
    euros=Ug_shillings/2280

    {
    Printf("%d/%d=%f\n",Ug_shillings,euro,euros)
    answer=float euros(euros);
    }

    /*Convert amount in Ug_shillings to pound_sterlings*/
    pound_sterling=3390
    pound_sterlings=Ug_shillings/3390

    {
    printf("%d/%d=%f\n",Ug_shillings,pound_sterling,pound_sterlings);
    answer=float pound_sterlings(pound_sterlings);
    }
    getch();
    return 0;
    }
     
    Last edited: Nov 3, 2006
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Rosnet Philomorpher Registered Senior Member

    Messages:
    681
    The error "statement missing" indicates that you've left out a semicolon ( ; ) somewhere, as you have done in nine places in this case...

    {

    /*Input amount in Ug_shillings to be converted*/

    printf("input amount to be coverted in Ug_shillings\n:");
    scanf("%d",&Ug_shillings);

    /*Convert amount in Ug-shinnings to dollars*/

    US_dollar=1850; /***** HERE *****/
    US_dollars=Ug_shillings/1850; /***** HERE *****/
    {
    printf("%d/%d=%f\n",Ug_shillings,US_dollar,US_dollars);
    Answer=float US_dollars(US_dollars);
    }

    /*Convert amount in Ug-shilling to SA_rands*/
    SA_rand=200; /***** HERE *****/
    SA_rands=Ug_shillings/200; /***** HERE *****/

    {
    printf("%d/%d=%f\n",Ug_shillings,SA_rand,SA_rands);
    answer=float SA_rands(SA_rands);
    }

    /*Convert amount in Ug_shillings to euro*/
    euro=2280; /***** HERE *****/
    euros=Ug_shillings/2280; /***** HERE *****/

    {
    Printf("%d/%d=%f\n",Ug_shillings,euro,euros); /***** HERE *****/
    answer=float euros(euros);
    }

    /*Convert amount in Ug_shillings to pound_sterlings*/
    pound_sterling=3390; /***** HERE *****/
    pound_sterlings=Ug_shillings/3390; /***** HERE *****/

    {
    printf("%d/%d=%f\n",Ug_shillings,pound_sterling,pound_sterlings);
    answer=float pound_sterlings(pound_sterlings);
    }
    getch();
    return 0;
    }
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. Rosnet Philomorpher Registered Senior Member

    Messages:
    681
    Actually there are even more errors here...
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. Rosnet Philomorpher Registered Senior Member

    Messages:
    681
    Oh wait a second, those are all functions??? Great!
     
  8. Kunax Sciforums:Reality not required Registered Senior Member

    Messages:
    2,385
    Code:
    cout << "will do your homework for free, only 12.99$ an hour";
    
     
  9. Rosnet Philomorpher Registered Senior Member

    Messages:
    681
    I can't understand your program, and it's easier to write another one, so...

    <Font face= "ms sans serif">
    #include &lt;stdio.h&gt;
    #include &lt;conio.h&gt;

    void main()
    {
    float UG_Shillings, US_Dollars, SA_Rands, Euros, Pound_Sterlings;

    clrscr();

    printf("Enter the amount in Uganda Shillings: ");
    scanf("%f",&UG_Shillings);

    US_Dollars=UG_Shillings/1850;
    SA_Rands=UG_Shillings/200;
    Euros=UG_Shillings/2280;
    Pound_Sterlings=UG_Shillings/3390;

    printf("\nValue in Dollars: %6.2f",US_Dollars);
    printf("\nValue in Rands: %6.2f",SA_Rands);
    printf("\nValue in US Euros: %6.2f",Euros);
    printf("\nValue in US Pounds Sterlings: %6.2f",Pound_Sterlings);

    getch();
    }
    </Font>
     
  10. Rosnet Philomorpher Registered Senior Member

    Messages:
    681
    I'll do it for free... Provided I'm bored enough and it's easy enough to type... And also provided so many other factors that in the end it'd be better to pay Kunax that $12.99.
     
  11. przyk squishy Valued Senior Member

    Messages:
    3,203
    Exactly what are you trying to do here:
    ?

    If "float US_dollars(US_dollars)" is a legal expression in C, I've never seen it before.

    Also:
    C is case sensitive - "Printf" is not the same as "printf", and:
    "US_dollar" isn't an integer.

    Lastly, there's this:
    It's perfectly legal C (provided you don't forget the semicolon), but it won't get you the result you're probably expecting. Since Ug_shillings is an int, the result of the division will be truncated. You can fix this by using a floating point constant instead of an integer in the expression (ie. use "1850.0" instead of "1850", or just use the variable "US_dollar").
     
Thread Status:
Not open for further replies.

Share This Page