Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: program

  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Malaysia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    program

    Dear sir,

    (a) How to create the below program?

    Write a program that produces a bill and coin breakdown for an amount of money. Initialize the amount in the float variable known as dollars and use the cents variable to keep track of the amount not yet converted to bills and coins. You will have to make use of integer arithmetic and the remainder in this program.

    Variables:
    dollars (float)
    cents (int)

    Output:
    The coin breakdown for 7.73 dollars is:
    Dollar bills: 7
    Fifty cents: 1
    Twenty cents: 1
    Ten cents: 0
    Five cents: 0
    One cents: 3


    (b) Refers to the below codes. Why the "5% Service Tax" amount can't be displayed?

    #include <stdio.h>
    #include <conio.h>

    void main()
    {
    int qty_sundae;
    int qty_meals;
    int qty_meal;
    float price_sundae = 1.05;
    float price_meals = 4.50;
    float price_meal = 6.10;
    float amt_sundae;
    float amt_meals;
    float amt_meal;
    float amount;
    float tax;
    float total;

    clrscr();
    printf("Enter no. of Sundae cones \t : ");
    scanf("%i", &qty_sundae);
    printf("Enter no. of Happy meals \t: ");
    scanf("%i", &qty_meals);
    printf("Enter no. of Extra value meal \t: ");
    scanf("%i", &qty_meal);

    printf("\nWelcome to MC Donald's\n");
    printf("Your Bill,\n");

    amt_sundae = qty_sundae * price_sundae;
    printf("\t %i Sundae cones \t :RM %5.2f\n", qty_sundae, amt_sundae);

    amt_meals = qty_meals * price_meals;
    printf("\t %i Happy meals \t\t :RM %5.2f\n", qty_meals, amt_meals);

    amt_meal = qty_meal * price_meal;
    printf("\t %i Extra value meal \t :RM %5.2f\n\n", qty_meal, amt_meal);

    amount = (amt_sundae + amt_meals + amt_meal);
    tax = amount * 0.05;
    printf("\t 5% Service Tax \t :RM %5.2f\n\n", tax);

    total = amt_sundae + amt_meals + amt_meal + tax;
    printf("Total Charges \t\t\t :RM %5.2f", total);
    getch();
    }


    Thanks,

    Xiang

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    This looks like a school homework assignment. We will not do your homework for you.

    Part a. you need to write the program yourself first and then if you have specific questions on programming and/or syntax then we can answer your questions.

    Part b. you need to elaborate on your question more.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please forgive Spookster for missing the fact that you did provide your code along with the assignment text, we get far too many who don't so it's almost a knee-jerk reflex to post that sort of a reply.

    Look at your program again, where does the "amount" variable get it's value set?

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by Roy Sinclair
    Please forgive Spookster for missing the fact that you did provide your code along with the assignment text, we get far too many who don't so it's almost a knee-jerk reflex to post that sort of a reply.

    Look at your program again, where does the "amount" variable get it's value set?
    I didn't miss any fact Roy. I believe they are asking for help on two different programs. No coding was provided for the first one Part (a). These are most likely school assignments though since it sounds like it was copied verbatim off an assignment sheet.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Spookster,

    You're right, I quick scanned the message assumed the code matched the assignment. However, I still provided only a hint instead of an answer since I do think it's important for people to have to figure things out for themselves.


  •  

    Posting Permissions

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