!!!Urgent Help on a group project!!!!!

This is a discussion on !!!Urgent Help on a group project!!!!! within the C Programming forums, part of the General Programming Boards category; Can anyone give me some insight into how to do this project? I have to have it done by the ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    4

    Exclamation !!!Urgent Help on a group project!!!!!

    Can anyone give me some insight into how to do this project? I have to have it done by the 16th (Tuesday) before class and I have no idea where to start. The programming assistant is gone for the year and I feel I'm S.O.L!!!

    Click Here for a Detailed Description of the project

    I must use this code to implement the new project.

    Code:
    #include <stdio.h>
    #define PARTS 50
    #define SALESPERSON 20
    #define NOT_FOUND -1
    
    int deParts(int [], char *[]);
    void deSales(int [][PARTS], int []);
    void listParts(int [], char *[], int);
    int search(int [], int); /*linear search*/
    void salesRpt(int [], int [][PARTS], char *[], char *[], int);
    
    main()
    {
    	int response, menu = 0;	
    	int count, match, part;
    
    	int partNum[PARTS] = {0};
    	char *partName[PARTS];
    	int sales[SALESPERSON][PARTS] = {0};
    	char *firstName[SALESPERSON] = {"John", "Sally", "Tim", "Michael", "Janet"};
    	char *lastName[SALESPERSON]= {"Smith", "Weill", "Lowell", "Dunn", "Keller"};
    
    
    	do
    	{
    	printf("MENU\n\n");
    	printf("1...........Data Entry of Parts\n");
    	printf("2...........Data Entry of Sales\n");
    	printf("3...........Print Parts Listing\n");
    	printf("4...........Search for Part Number\n");
    	printf("5...........Print Sales Report\n");
    	printf("6...........End Program\n");
    
    	printf("Please select an option then press the enter key.\n");
    	scanf("%d", &response);
    
    	switch(response)
    	{
    	case 1:
    		count = deParts(partNum, partName); /* pass part # int array & part name ptr array) */
    		printf("\n\n%d\n\n", count);
    		break;
    
    	case 2:
    		deSales(sales, partNum); /* pass sales qty 2D array & part number int array */
    		break;
    
    	case 3:
    		listParts(partNum, partName, count); /* pass part # int array; part name ptr array
    											 & my part number counter */
    		break;
    
    	case 4:
    		printf("Enter part number: ");
    		scanf("%d", &part);
    		match = search(partNum, part); /* pass part # int array and part number to search for */
    		if(match == NOT_FOUND)
    			printf("Part number %d is not valid.", part);
    		else
    			printf("\n\n%-10d%-20s\n", part, partName[match]);
    		break;
    
    	case 5:
    		salesRpt(partNum, sales, firstName, lastName, count); /* pass part # int array,
    															  sales qty array, first & last
    															  name arrays, and part count */
    		break;
    
    	case 6:
    		printf("\n\n Thanks for using this program!\n\n");
    		menu = 1;
    		break;
    	}
    
    	}while (menu == 0);
    	return 0;
    }
    
    int deParts(int number[], char *name[])
    {
    	int ans=0;
    	char loop;
    	char partName[20][20];
    	static int counter=0;
    
    	while (ans == 0)
    	{
    		printf("Please enter the part number, then press the enter key.\n");
    		scanf("%d", &number[counter]);
    		printf("\n\nPlease enter the part name, then press the enter key.\n");
    		fflush(stdin);
    		scanf("%s", partName[counter]);
    		name[counter] = partName[counter];
    		printf("it saved");
    		printf("\n%s\n", name[counter]); 
    		counter++;
    	
    		
    		printf("\n\nWould you like to enter another part number and name? Y or N\n");
    		fflush(stdin);
    		scanf("%c", &loop);
    		if (loop == 'n' || loop == 'N')
    			ans = 1;
    	}
    	printf("\n\nPlease choose another menu option.\n");
    	return counter;
    }
    
    void deSales(int people[][PARTS], int partNumbers[])
    {
    	int id, part, match, loop1=0, loop2=0;
    	char response;
    	printf("\n\nHere you can enter how many parts each salesperson has sold.\n\n");
    	while(loop1 == 0)
    	{
    		printf("Please enter the salesperson's ID number.\n");
    		scanf("%d", &id);
    		while(loop2 == 0)
    		{
    			printf("\n\nNow you can enter a part number and the quantity the salesperson sold.\n");
    			printf("Part number:  ");
    			scanf("%d", &part);
    			match = search(partNumbers, part);
    			if(match == NOT_FOUND)
    				printf("This part number is not valid.");
    			else
    			{
    				printf("\nQuantity:  ");
    				scanf("%d", &people[id][match]);
    			}
    			printf("Enter another part number and quantity? Y or N \n");
    			fflush(stdin);
    			scanf("%c", &response);
    			if(response == 'n' || response == 'N')
    				loop2 = 1;
    		}
    	printf("Would you like to enter sales for another salesperson? Y or N\n");
    	fflush(stdin);
    	scanf("%c", &response);
    	if(response == 'y' || response == 'Y')
    		loop2 = 0;
    	if(response == 'n' || response == 'N')
    		loop1 = 1;
    	}
    }
    
    void listParts(int partNo[], char *names[], int cnt)
    {
    	int i;
    	printf("Parts Listing\n\n");
    	printf("%-10s%-20s\n", "Number", "Name");
    	for (i=0; i<=cnt-1; i++)
    	{
    		printf("%-10d", partNo[i]);
    		printf("%-20s\n", names[i]);
    	}
    }
    
    int search(int partNo[], int key)
    {
    	int i=0, found=0, where;
    	while (!found && i < PARTS)
    	{
    		if (partNo[i] == key)
    			found = 1;
    		else
    			++i;
    	}
    	printf("completed loop");
    	if(found)
    		where = i;
    	else
    		where = NOT_FOUND;
    
    	printf("assigned where value");
    	return (where);
    }
    
    void salesRpt(int partNo[], int salesData[][PARTS], char *first[], char *last[], int cnt)
    {
    	int i, j, total;
    	printf("Weekly Parts Sales Report\n\n");
    	for (i=0; i<5; i++) 
    	{
    		total = 0;
    		printf("%s %s\n", first[i], last[i]);
    		printf("        %-20s%-10s\n", "Part Number", "Quantity");
    		for (j=0; j<=cnt-1; j++)
    		{
    			printf("        %-20d%-10d\n", partNo[j], salesData[i][j]);
    			total = total + salesData[i][j];
    		}
    		printf("                Total       %d\n\n", total);
    	}
    		
    }
    Please Help!!!

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    What part do you need help with? What have you done so far? Have you read the FAQ? Have you read the rules regarding posting?

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    4
    Sorry....Please forgive my ignorance. First off, this is merely extra credit, not a legitimate homework assignment. I apologize for imposing it as hw, and also for using the scorned word urgent in the subject. Im simply being put through the wringer with finals and other b.s. and just can't quite hack this problem. If there is anyone out there who can help me out? Thanks in advance...

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    PC-lint for C/C++ (NT) Ver. 8.00e, Copyright Gimpel Software 1985-2001
    --- Module: test.c
    test.c 20 [Info 785] Too few initializers for aggregate
    test.c 21 [Info 785] Too few initializers for aggregate
    test.c 49 [Warning 644] Variable 'count' (line 15) may not have been initialized
    test.c 60 [Warning 644] Variable 'partName' (line 18) may not have been initialized
    test.c 73 [Info 744] switch statement has no default
    test.c 93 [Warning 684] Passing address of auto variable 'partName' into caller space


    strcpy

    FAQ
    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.*

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, 09:05 AM
  2. ray casting
    By lambs4 in forum Game Programming
    Replies: 62
    Last Post: 01-09-2003, 05:57 PM

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