1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
#include"stdafx.h"
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
void convert(char *a);
void lower(char *storeinput);
void ReadProduct(const char* productName,product_t &product);
typedef struct{
char name[20];
int demandrate;
double setupcost;
double unitcost;
double inventorycost;
double sellingprice;
double weeks;
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 chocolate;
product_t tea;
product_t cake;
product_t pie;
}stores_t;
stores_t callaghan;
stores_t lambton;
int main(void)
{
int selection=0;
FILE *f_in;
char store1[15]="lambton";
char store2[15]="callaghan";
char cancel[10]="cancel";
char STOREinput[15];
char storeinput[15];
char productinput[15];
char coffee[10]="coffee";
char chocolate[10]="chocolate";
char tea[10]="tea";
char cake[10]="cake";
char pie[10]="pie";
while (true){
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)
{
}
if (selection == 2)/*Input data*/
{
printf("INPUT DATA\n");
do{
printf("Please,input the name of the store:\n(type 'cancel' to return to the previous menu) >");
scanf("%s",&storeinput);
lower (storeinput);
if(strcmp (storeinput,store1) ==0 ){/*Lambton*/
printf("Please, input the name of the product: >");
scanf ("%s",productinput);
lower (productinput);
if (strcmp (productinput,cancel) ==0){
break;
}else if( strcmp (productinput,coffee) ==0){
ReadProduct(coffee,lambton.coffee);
}else if(strcmp (productinput,chocolate) ==0){
ReadProduct(chocolate, lambton.chocolate);
}else if(strcmp (productinput,tea) ==0){
ReadProduct(tea, lambton.tea);
}else if(strcmp (productinput,cake) ==0){
ReadProduct(cake, lambton.cake);
}else if(strcmp (productinput,pie) ==0){
ReadProduct(pie, lambton.pie);
}
}else if( strcmp (storeinput,store2) ==0){ /*Callaghan*/
printf("Please, input the name of the product: >");
scanf ("%s",productinput);
lower (productinput);
if (strcmp (productinput,cancel) ==0){
break;
}else if( strcmp (productinput,coffee) ==0){
ReadProduct(coffee, callaghan.coffee);
}else if(strcmp (productinput,chocolate) ==0){
ReadProduct(chocolate, callaghan.chocolate);
}else if(strcmp (productinput,tea) ==0){
ReadProduct(tea, callaghan.tea);
}else if(strcmp (productinput,cake) ==0){
ReadProduct(cake, callaghan.cake);
}else if(strcmp (productinput,pie) ==0){
ReadProduct(pie, callaghan.pie);
}
}else if( strcmp (storeinput,cancel) ==0){
break;
}else{
printf("No such store Found");
}
}while(true);
}
if (selection == 3)
{
}
if (selection == 4)
{
}
if (selection == 5)
{
}
if (selection == 6)
{
}
}
return(0);
}
void lower(char *storeinput){
int i,z;
z = strlen(storeinput);
for(i=0;i<=z;i++){
storeinput[i]=tolower(storeinput[i]);
}
}
void ReadProduct(const char* productName, product_t& product){
printf("Please, input the demand rate of %s: >");
scanf("%d",&product.demandrate);
printf("Please, input the setup cost of %s: >");
scanf("%d",&product.setupcost);
printf("Please, input the unit cost of %s: >");
scanf("%d",&product.unitcost);
printf("Please, input the inventory cost of %s: >");
scanf("%d",&product.inventorycost);
printf("Please, input the selling price of %s: >");
scanf("%d",&product.sellingprice);
printf("Please, input the number of %s: >");
scanf("%i",&product.weeks);
}
|