Thread: can't figure it out HELP

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    25

    can't figure it out HELP

    Was assigned a homework ass. And the teacher and book are not to helpfull.

    I am supposed to determine if a store customer has exceeded the credit limit on his charge account. For each customer the facts are available. Account number, balance at the beginning of the mounth, total of all item charged by customer this month, total of all credits applied to customer's account this month, and allowed credit limit.
    We have studied the if, if-else and while strutures only, can any one give me a hand at this program.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Whe usually don't create an entire program, ecspecially if it's
    homework, So if you could plz post some of the code you already
    programmed, You should be able to construct at least the base.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    As per above, I usually don't do people's homework for them. However, I'm feeling generous today, so you're in luck! I'll get you started. You fill in the blanks:
    Code:
    blanks
    
    int main ( void )
    {
        blanks
    
        return 0;
    }
    Now that I've done the hard part, all you have to do is fill in two little blanks, and you're done!

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    Ahh gee thks for help lol. I know u guys dont do homework for ppl but I need some help at this, this is what I have done so far ok. Could u tell me if I am on the right track or just wasting my time.

    include<stdio.h>

    int main()

    {
    int account_number, total_items

    float balance, total_credits, allowed_credits


    printf("Enter account number%d\n", acount_number);
    scanf ("%d", &account_number

  5. #5
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    No, you're not wasting your time, you're in the correct way.
    Now, did you understand what they want from you?
    determine if a store customer has exceeded the credit limit on his charge account

    This is not so hard, first of all think in your head, how could you solve this, without programming, after this, try programming, and it will be easier for you.

    If you understand well, how if's works, you can do it easilly.

  6. #6
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    It says to input each of these facts, calculate the new balance (=beginning balance + charges -credits) determine if the new balance exceeds the customer's credit limit. For those customer's whose credit limit is exceeded, the program should display the customer's account number, credit limit, new balance ane the message Credit limit exceeded.
    I am so confused book does not give any examples and teacher didn't give any notes for it either lol. I just need some help here plz.

  7. #7
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    Ok, you learned to input data, you have 2 types of variables:
    Ineteger and Float, to input integer use:

    Code:
    scanf("%d",&varName);
    And for input float, use:
    Code:
    scanf("%f",&varName);
    Not input all that you need to input, paste your code here, and we'll go to the next level

  8. #8
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    This is as far as I have gotten

    #include<stdio.h>

    int main()
    {
    int account_number,total_items;
    float balance, total_credits, allowed_credits;


    printf ("Enter in account number\n");
    scanf ("%d", &account_number);
    printf ("account number is%d\n");

    return 0;

    }

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Let me save you the trouble of typing a reply after every line of code you write.
    Code:
    while not done
        prompt for account number
            look up account number
            if not found, create new account
                probably prompt for credit limit
                possibly prompt for initial balance
        prompt for action
            -- check balance
            -- pay towards bill
            -- charge something
    See the above? We call that pseudo-code. Pseudo-code is a method of outlining what you want the program to do. Break each step down into smaller steps.

    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>This is as far as I have gotten
    And your next step is to learn code tags

    >>printf ("account number is%d\n");
    Should be
    >>printf ("account number is %d\n", account_number);
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  11. #11
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    I wrote this program but it doesnt compile any help
    Code:
    include<stdio.h>
    int main()
    {
        int acc1;
        float bal, chrg, cred, limit;
        
        printf ("Enter account number (-1 to end);\n");
        scanf ("%d", &acct1);
        
        while (acct != -1){
            printf ("enter begining balance:\n");
            scanff ("%f", &bal);
            printf ("enter total charges:\n")l;
            scanf ("%f", &chrg);
            printf ("Enter total credits!\n");
            scanf ("%f", &cred);
            printf ("Enter total credit limit:\n");
            scanf ("%f", &limit);
            
            bal=(bal+chrg)-cred;
            if (bal>limit);{
            
            printf ("account:%d", acct);
            printf ("credit limit: %.2f\n",limit);
            printf ("balance limit exceded\n");
            }
          
          }
            return 0;
            }

  12. #12
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    *change include<stdio.h>

    into #include <stdio.h>

    u wrote somewhere scanff its scanf (one f)

    <<printf ("enter total charges:\n")l;
    drop the l ==>
    printf ("enter total charges:\n");

    u declare int acc1; but u use acct1 :s change that acct1 into acc1;
    <<if (bal>limit);{
    drop the ; ==>if (bal>limit){
    Code:
    #include <stdio.h>
    int main()
    {
    	 int acct;
    	 float bal, chrg, cred, limit;
    
        printf ("Enter account number (-1 to end)\n");
    	 scanf ("%d", &acct);
    
        while (acct != -1){
            printf ("enter begining balance:\n");
    		  scanf ("%f", &bal);
    		  printf ("enter total charges:\n");
    		  scanf ("%f", &chrg);
    		  printf ("Enter total credits!\n");
            scanf ("%f", &cred);
    		  printf ("Enter total credit limit:\n");
    		  scanf ("%f", &limit);
            
    		  bal=(bal+chrg)-cred;
    		  if (bal>limit){
    
    		  printf ("account:%d", acct);
    		  printf ("credit limit: %.2f\n",limit);
    		  printf ("balance limit exceded\n");
    		  }
    
    		}
    		  return 0;
    		  }
    the corrections i made where just corrections that were indicated by the compiler try to look urself at compiler warnings and errors this way u will solve lots of typos and other things
    ::edit::
    also try to use some indentations this way code is easier to read (im looking at the if statement right now)
    Last edited by GanglyLamb; 02-06-2003 at 02:07 PM.

  13. #13
    Registered User
    Join Date
    Feb 2003
    Posts
    7
    Alright. I'm fairly new to C programming myself, so maybe it's a good idea to disregard any and all of my advice. Still...

    printf ("Enter account number (-1 to end);\n");

    I don't think that the semicolon after the (-1 to end) is possible. That's an error, I think. Also, if this is an exact copy from your C source...

    scanff ("%f", &bal);

    That scanf has one two many F's in it.

    Maybe I'm wrong, but that's what I see.

  14. #14
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    thank u

  15. #15
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    I don't think that the semicolon after the (-1 to end) is possible. That's an error, I think. Also, if this is an exact copy from your C source...
    thats not an error it will just print ';' to the screen without any thing else (because the ';' sign is within the "blabla" of the printf)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Figure out how method was called?
    By jcafaro10 in forum C++ Programming
    Replies: 2
    Last Post: 02-07-2009, 10:43 AM
  2. 3 dimensional figure volume
    By thekautz in forum C++ Programming
    Replies: 2
    Last Post: 01-20-2009, 05:22 PM
  3. trying to figure out someone's code for a plugin
    By paulpars in forum C++ Programming
    Replies: 4
    Last Post: 07-20-2006, 10:57 AM
  4. newb to C, cant figure something out.
    By Phate4219 in forum C Programming
    Replies: 16
    Last Post: 03-06-2006, 01:47 AM
  5. ahh i can't figure out this loop
    By blindleaf in forum C Programming
    Replies: 1
    Last Post: 03-18-2003, 09:42 AM