Please check this coding for me!

This is a discussion on Please check this coding for me! within the C Programming forums, part of the General Programming Boards category; I was asked to write a simple billing system. So this is the code i can come up with. I ...

  1. #1
    Divine
    Join Date
    Oct 2007
    Location
    Earth(duh!)
    Posts
    20

    Please check this coding for me!

    I was asked to write a simple billing system. So this is the code i can come up with. I know there are some mistakes there but i can't figure what is it. Please, check it for me and correct it.

    Code:
    /*Updating a Series of Customer Accounts(simplified billing system)*/
    
    #include <stdio.h>
    
    void readinput(int i)
    void writeoutput(int i)
    
    struct date{
    	int month;
    	int day;
    	int year;
    };
    
    
    struct account
    {
    	char name[40];
    	char street[40];
    	char city[40];
    	int acct_no;
        float previous_balance;
    	float current_payment;
    	float new_balance;
        struct date lastpayment;	
    }
    customer[100];
    
    main()
    
    {
    	int i,n;
    
    	printf("CUSTOMER BILLING SYSTEM\n\n");
    	printf("How many customer are there?");
    	scanf("%d",&n);
    
    
    	{
    		readinput(i);
    
    		customer[i].new_balance=customer[i].previous_balance-customer[i]current_payment;
    	}
    	
    	
    
       
    	
    
    
    
    
    	
    
    		writeoutput(i);
    }
    
    void readinput(int i)
    
    {
    
    	printf("Customer no.%d\n",i+1);
    	
    	printf("   Name:");
        scanf("%[^\n]",customer[i].name);
    
    	printf("   Street:");
        scanf("%[^\n]",customer[i].street);
    
    	printf("   City:");
        scanf("%[^\n]",customer[i].city);
    
    	printf("   Account number:");
    	scanf("%d",&customer[i].acct_no);
    
    	printf("   Current payment:");
    	scanf("%f",&customer[i].currentpayment);
    
    	printf("   Payment date (mm/dd/yyyy):");
    	scanf("%d%d%d",&customer[i].month,
    		           &customer[i].day,
    				   
    
    	return;
    
    }		
    
    void writeoutput(int i);
    
    {
    	printf("\nName:   %s",customer[i].name);
    
    	printf("   Account number:%d\n",customer[i].acct_no);
    
    	printf("Street:   %s\n",customer[i].street);
    
    	printf("City   %s\n\n",customer[i].city);
    
    	printf("Previous Balance: %7.2f",customer[i].previousbalance);
    
    	printf("   Current Payment: %7.2f", customer[i].currentpayment);
    
    	printf("   New balance: %7.2f\n\n",customer[i].newbalance);
    
        return;
    	
    }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And what are the symptoms of these mistakes?

    Do you go to your doctor saying "I don't feel well" and expect the doctor to immediately know that it's your foot that hurts?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    A development process
    Step 1 is don't write more code than you're prepared to deal with being wrong when you try to compile it.

    Writing 10 lines, compile and fix 1 error - good.
    Writing 100 lines, compile and getting lots of errors - bad. Especially if you then dump the whole sorry mess on a message board for someone else to fix.

    I might care if it was nicely indented and made good use of blank lines to separate different areas of the code, but it doesn't even manage to do that.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. how to check input is decimal or not?
    By kalamram in forum C Programming
    Replies: 3
    Last Post: 08-31-2007, 07:07 PM
  3. Replies: 3
    Last Post: 07-24-2007, 04:25 PM
  4. Please check this loop
    By Daesom in forum C++ Programming
    Replies: 13
    Last Post: 11-02-2006, 12:52 AM
  5. check my code ( if statement, file existance )
    By Shadow in forum C Programming
    Replies: 1
    Last Post: 10-04-2001, 11:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21