Hello all. This program is supposed to maintain inventory for 5 warehouses with 3 items each warehouse. Each in a different city. You can place an order or send a shipment to each warehouse. When you place an order, if one warehouse does not have enough of the item it searches through other warehouses to fulfill the order. If it finds one to fulfill the order, it takes from that warehouse and adds 10% to the price of the order. If it cannot find a warehouse to fulfill the order it simply says "Order Unfilled". I have the following code and rather than search through other warehouses, it simply says "Order Unfilled", even when other warehouse have enough product to fulfill. I would appreciate any advice, thank you in advance.
switch(ch){
case 1:
int quantityamount1[3];
for(int i=0;i<3;i++){
cout<<"Enter quantity for item "<<i+1<<":\n";
int quantity=0;
cin>>quantity;
if(quantity<=wh[0].amt[i] && wh[0].amt[i]>0){ //Searching current warehouse inventory
wh[0].amt[i]-=quantity;
quantityamount1[i]=quantity;
}else{
for(int j=0;j<5;j++){
if(wh[j].amt[i]>0 && quantity<=wh[j].amt[i]){//Searching other warehouses to fulfill order
cout<<quantity<<" quantity of item "<<i<<" shipped from "<<wh[j].city<<" to "<<wh[i].city<<"\n";
wh[j].amt[i]-=quantity;
cout<<wh[j].city<<" "<<wh[j].amt[0]<<" "<<wh[j].amt[1]<<" "<<wh[j].amt[2]<<"\n";
break;
}else{
cout<<"Order Unfilled\n";//Could not find any warehouses to fulfill order
quantityamount1[i]=1;
break;
}
}
quantityamount1[i]=quantity;
}
}
Here is my warehouse data:
char ch;
wh[0].city="New York";
wh[0].amt[0]=40;
wh[0].amt[1]=33;
wh[0].amt[2]=43;
wh[1].city="Los Angeles";
wh[1].amt[0]=25;
wh[1].amt[1]=23;
wh[1].amt[2]=26;
wh[2].city="Miami";
wh[2].amt[0]=43;
wh[2].amt[1]=23;
wh[2].amt[2]=53;
wh[3].city="Houston";
wh[3].amt[0]=35;
wh[3].amt[1]=35;
wh[3].amt[2]=35;
wh[4].city="Chicago";
wh[4].amt[0]=21;
wh[4].amt[1]=21;
wh[4].amt[2]=21;