Help on project

This is a discussion on Help on project within the C Programming forums, part of the General Programming Boards category; Hayy, I need help on the project for my EGR 115 Computer Engineering class. I was wondering if you could ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    3

    Help on project

    Hayy, I need help on the project for my EGR 115 Computer Engineering class. I was wondering if you could help. I would like to post project but I can't. You can find the project guidelines on http://egr115.kindy.net/ and it is program #5.

    This is what I have so far:
    Code:
    #include "stdio.h"
    #include "stdlib.h"
    
    main(){
        
        1.
        
        file handle: file*imput;
        FILE*imput: printf("Enter Item Number");
        fflush(stdin);
        fscanf(file "%d", &x);
        FILE*imput, *ouput;
        FILE*return Quantity;
        
        2.
        
        file handle: File*imput;
        FILE*imput: printf("Enter Item Number");
        fflush(stdin);
        fscanf(file "%d" &x);
        FILE*return Price;
        
        3.
        
        file handle: File*imput;
        FILE*imput: printf("Enter Item Number");
        FILE*imput: printf("Enter Item Quantity");
        fflush(stdin);
        fscanf(file "%d", &x);
        FILE*imput,*output;
        FILE*return Tax Code;
        
        
        4.
        
        File handle: File*imput;
        FILE*imput: printf("Enter Item Number");
        fflush(stdin);
        fscanf(file "%d", &x);
        FILE*quantity;
        FILE*return Tax Due
        
        system ("pause");
    }//end of main


    Thanks for the help.

  2. #2
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195
    Can I get your instructors email address so I can email him or her the solution?

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    I'd say start with what is given. (Although this isn't encouraging):
    Code:
    #include "stdio.h"
    #include "stdlib.h
    Then look into the FAQ. Then post your updated code.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    Registered User
    Join Date
    Jan 2006
    Location
    Berkeley, Ca
    Posts
    195
    Dave, hasn't something like

    Code:
    main() {
    
    }
    been depreciated since 1989?

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by cdalten
    Dave, hasn't something like

    Code:
    main() {
    
    }
    been depreciated since 1989?
    Something like that.
    http://faq.cprogramming.com/cgi-bin/...&id=1043284376

    [edit]Implicit function declaration was not deprecated in C89/90, but it was deleted in C99.
    Last edited by Dave_Sinkula; 03-14-2006 at 09:19 PM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  6. #6
    Registered User
    Join Date
    Mar 2006
    Posts
    3
    Ok, I got it now, but now I need help on the switch case function to compute the tax.

    Code:
    #include "stdio.h"
    #include "stdlib.h
    #define	FILENAME			"db.txt"
    #define	RECEIPT_FILE	"receipt.txt"
    #define	TAXRATE			0.065
    
    
    int Lookup_Item_Quantity(FILE *db, int item);
    double Lookup_Item_Price(FILE *db, int item);
    char Lookup_Item_Taxability(FILE *db, int item);
    double Compute_Tax(FILE *db, int item, int qty);
    int Remove_Qty_From_Inventory(FILE *db, int item, int qty);
    int Create_Receipt(FILE *db, int items[][2], int itemcnt);
    
    main() {
    int Q;
    double price;
    char tax;
        
        FILE*db;
        db=fopen("db.txt", "r+");
        Q=Lookup_Item_Quantity(db, 333333);
        printf("%i", Q);
        
        FILE*db;
        db=fopen("db.txt", "r+");
        Price=Lookup_Item_Price(db, 333333);
        printf("%lf", price);
        
        FILE*db;
        db=fopen("db.txt","r+");
        tax=Lookup_Item_Taxability(db, 333333);
        printf("%c", tax);
        
        FILE*db;
        db=fopen("db.txt", "r+");
        ComputeT=Compute_Tax(db, 33333);
        printf("%i", "%lf", Q,Item);
    	
    	
    	
    } // end of main()
    
    int Remove_Qty_From_Inventory(FILE *db, int item, int qty){
    
    	int		rval=1;
    	FILE		*db2 = fopen("temp.txt", "w");
    
    
    	// ...
    	// YOUR CODE GOES HERE...
    	// Copy everything over from the db.txt file
    	//  over to the temp.txt file -- be sure to
    	//  subtract qty from the proper item
    	// ...
    	
    	
    
    	// This code renames the temporary file	
    	// to be the new database file
    	fclose(db);
    	fclose(db2);
    	remove(FILENAME);
    	rename("temp.txt", FILENAME);
    	db = fopen(FILENAME, "r+");
    	
    	
    	return rval;
    	
    } // end of Remove_Qty_From_Inventory()
    
    
    int Lookup_Item_Quantity(FILE *db, int item){
        while (in !=item){
            fscanf(db, "%i", &in);
            fscanf(db,"%lf\n" &price);
            fscanf(db, "%c", &tax);
            fscanf(db, "%i", &Q);
        }//end of while
        return Q;
    	
    } // end of Lookup_Item_Quantity()
    
    
    double Lookup_Item_Price(FILE *db, int item){
        while (in !=item){
            fscanf(db, "%i", &in);
            fscanf(db,"%lf\n" &price);
            fscanf(db, "%c", &tax);
            fscanf(db, "%i", &Q);
        }//end of while
        return price;
    	
    } // end of Lookup_Item_Price()
    
    
    char Lookup_Item_Taxability(FILE *db, int item){
        while (in !=item){
            fscanf(db, "%i", &in);
            fscanf(db,"%lf\n" &price);
            fscanf(db, "%c", &tax);
            fscanf(db, "%i", &Q);
        }//end of while
        return tax;
    	
    } // end of Lookup_Item_Taxability()
    
    
    double Compute_Tax(FILE *db, int item, int qty){
        switch(tax, Q){
            case 'O'
            case 'T'
            case 'N'
        }//end of switchcase
            
    	
    } // end of Compute_Tax()
    
    int Create_Receipt(FILE *db, int items[][2], int itemcnt){
    	
    } // end of Create_Receipt()
    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 10:05 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 02:30 PM
  3. Dynamic Binding
    By gpr1me in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2006, 09:01 AM
  4. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 08:41 PM

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