#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Help in Assignment


    Hi everyone i am new to this forum and need some help :)
    i am working on my assignment and stuck in between and im not getting a way out.
    The program is about a coffee shop brand which have two shops in suburbs of lambton and callaghan.
    and each shop have 5 products coffee,chocolate,tea,cake,pie.
    and each product have some data which the owner need to be aware of like name of product,demand rate,setup cost,unit cost,inventory cost,selling price,and another calculated value EOQ(economic Order Quantity).
    on basis of this we need to make a program with the first screen asking for input from user like this.
    Code:
    1) Read file
    2) input data
    3) display store
    4) display product
    5) save file
    6) exit
    their will be no .txt file in the beginning and one will be made after the first time the user will input the data using option 2.

    and the code for now i have is this
    Code:
    #include <string.h>
    #include "stdafx.h"
    #include<math.h>
    #include<stdio.h>
    
    typedef struct{
    	char name[12];
    	int demandrate;
    	double setupcost;
    	double unitcost;
    	double inventorycost;
    	double sellingprice;
    	double eoq;
    }product_t;
    
    product_t coffee;
    product_t choc;
    product_t tea;
    product_t cake;
    product_t pie;
    
    typedef struct{
    	product_t coffee;
    	product_t choc;
        product_t tea;
        product_t cake;
        product_t pie;
    }stores_t;
    stores_t callaghan;
    stores_t lambton;
    
    
    	
    
    
    					
    
    int main(void)
    {
    	int selection;
        FILE *f_in;
    	char store1[8]="lambton";
    	char store2[11]="callaghan";
    
    
    	printf("Welcome To Bestbean Coffee Replenishment System\n");
    	printf(" 1.Read File\n 2.Input Data\n 3.Display Store\n 4.Display Product\n 5.Save File\n 6.Exit\n What Would you Like To Do?(1-6)\n >");
    	scanf("%i",selection);
    	
    	if (selection == 1);{/*Read File*/
    		f_in =fopen("input.txt","r");
    		if (f_in == NULL){
    			printf("No File Found");
    		}
    		else{
    			fscanf("%s
    			
    		}
    
    
    
    	}
    
    
    	if (selection == 2);{/*Input Data*/
    
    	}
    
    	if (selection == 3);{/*Display Store*/
    	}
    
    	if (selection == 4);{/*Display Product*/
    	}
    
    	if (selection == 5);{/*Save File*/
    	}
    
    	if (selection == 6);{/*Exit*/
    	}
    
    	
    
    
    
    
    	return 0;
    }
    i am not a good programmer as its been just 8 weeks in the subject for me.
    i dont want full written code from anyone (if anybody's willing he/she can :p :D ) lol
    now first problem is the option 1 in program screen "read file"
    in this we will read the file. the sample file is like this
    Code:
    Lambton:
    
    Name: chocolate
    demand rate: 50
    setup cost: 200
    unit cost: 5.2
    inventory cost: 2
    selling price: 3
    
    weeks: 6
    
    Name: cake
    demand rate: 50
    setup cost: 300
    unit cost: 4
    inventory cost: 2
    selling price: 3.1
    
    weeks: 12
    
    Callaghan:
    
    Name: coffee
    demand rate: 100
    setup cost: 200.5
    unit cost: 4
    inventory cost: 2.1
    selling price: 2
    
    weeks: 50
    how will we read the file in this like we dont want the strings name ,demand rate etc. we just want to read the integers after that. but we do need to keep checking for callaghan or lambton in each line so the store changes.
    can someone help me anyways or give a sample code for reading and writing because i am stuck to this from 2 days and searching internet forums but all in vain. still got 12 days for this :)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    159
    Rep Power
    19
    now first problem is the option 1 in program screen "read file"
    in this we will read the file. the sample file is like this
    Why is this the first problem? You said:
    their will be no .txt file in the beginning and one will be made after the first time the user will input the data using option 2.
    So this should actually be the first thing you work on finishing. After you get the user input part working you need to work on the display routine, so you know you are entering the data correctly. Then you need to get your file writing functions done so you can save the information, this should be very similar to the display routines. Then once you have the file writing done, you can then work on your file reading functions.


    Jim

IMN logo majestic logo threadwatch logo seochat tools logo