Closed Thread
Results 1 to 8 of 8

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

  1. #1
    Registered Member
    Posts
    1

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

    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_sterlin gs);
    answer=float pound_sterlings(pound_sterlings);
    }
    getch();
    return 0;
    }
    Last edited by jdibya; 11-03-06 at 06:54 AM. Reason: The program has #include<stdio> and #include<conio> but they do not appear

  2. #2
    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_sterlin gs);
    answer=float pound_sterlings(pound_sterlings);
    }
    getch();
    return 0;
    }

  3. #3
    Actually there are even more errors here...

  4. #4
    Oh wait a second, those are all functions??? Great!

  5. #5
    Sciforums:Reality not required Kunax's Avatar
    Posts
    2,385
    Code:
    cout << "will do your homework for free, only 12.99$ an hour";

  6. #6
    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>

  7. #7
    Quote Originally Posted by Kunax View Post
    Code:
    cout << "will do your homework for free, only 12.99$ an hour";
    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.

  8. #8
    Exactly what are you trying to do here:
    Answer=float US_dollars(US_dollars);
    ?

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

    Also:
    Answer=float US_dollars(US_dollars);
    Printf("%d/%d=%f\n",Ug_shillings,euro,euros);
    C is case sensitive - "Printf" is not the same as "printf", and:
    printf("%d/%d=%f\n",Ug_shillings,US_dollar,US_dollars);
    "US_dollar" isn't an integer.

    Lastly, there's this:
    US_dollars=Ug_shillings/1850;
    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").

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •