- Nov 28, 2000
- 6
- 0
- 0
The program <scroll down to the bottom> doesn't run properly. Can someone please check my program if it does the following:
ask the user:
sqfeet of store(min 4000 and max 8000)
total square feet of building (min=sqfeet of store, max=32000)
sqfeet of warhouse space(min=2000, max=sqfeet of store-1000)
sqfeet of store MUST be 25% of building if not, stop the program, ask the user if they want to continue to analyze another building, and repeat all the questions
sqfeet of warehouse must be 30% of store if not,stop the program, ask the user if they want to continue to analyze another building, and repeat all the questions
use the following functions:
int GetSqfeet(int min, int max)
Used to input all of the square footage amounts. THe input value must be >=min and <=max. The building cannot be processed until the square footage is correct. Note that min and max will be different depending on which value is being input.
int inRange(int sqfeet, int minpercent, int total)
used to verify the secondary conditions. Returns a 1 if its within range or a 0 if its to be rejected.
WHAT I AM HAVING TROUBLE WITH:
a) if I enter for example the sqfeet of the store to be 5000 and the building to be 10000( it is 50% of the building), it still asks me if I want to continue but the percentage is greater than 25.
b) When it does ask me if I want to continue, if I press no, it goes on again.
c) when it repeats, it doesn't start from the beginning (asking the sqfeet of store). It jumps to the sqfeet of the warehouse.
IF U RUN THE PROGRAM, U WILL NOTICE ALL THOSE ERRORS.
I WOULD REALLLLLLYYYY APPRECIATE IF SOMEONE HELPS ME OUT.
# include <stdio.h>
int GetSqfeet();
int inRange();
main()
{
int min=4000;
int max=8000;
int stfeet;
int sqfeet_building;
int minpercent;
int total;
int sqwarehouse;
int range_building;
int range_warehouse;
char answer;
int sqfeet;
clrscr();
do
{
stfeet=GetSqfeet(min,max);
min=stfeet;
max=32000;
sqfeet_building=GetSqfeet(min,max);
total=sqfeet_building;
minpercent=25;
sqfeet=stfeet;
range_building=inRange(sqfeet,minpercent, total);
if (range_building==0)
{
printf("Do you wish to continue"
;
answer=getche();
}
min=2000;
max=stfeet-1000;
sqwarehouse=GetSqfeet(min,max);
sqfeet=sqwarehouse;
total= stfeet;
minpercent=30;
range_warehouse=inRange(sqfeet, minpercent, total);
if(range_warehouse==0)
{
printf("Do you wish to continue"
;
answer=getche();
}
} while(answer!='y' || answer!='Y');
return;
}
int GetSqfeet(int min, int max)
{
int sqfeet;
if (max==8000)
{ printf("Enter the square footage of the store: "
;
scanf("%d",&sqfeet);}
if(max==32000)
{ printf("Enter the square footage of the building: "
;
scanf("%d",&sqfeet);}
if(min==2000)
{ printf("Enter the square footage of the warehouse: "
;
scanf("%d",&sqfeet);}
do
{
if((sqfeet<min) || (sqfeet>max))
{
printf("Sorry, that is not within the range:"
;
scanf("%d",&sqfeet);
}
}while (sqfeet<min || sqfeet>max);
return(sqfeet);
}
int inRange(int sqfeet, int minpercent, int total)
{
int percent;
int range;
percent=(sqfeet/total)*100;
if(percent>=minpercent)
range=1;
else
range=0;
return(range);
}
ask the user:
sqfeet of store(min 4000 and max 8000)
total square feet of building (min=sqfeet of store, max=32000)
sqfeet of warhouse space(min=2000, max=sqfeet of store-1000)
sqfeet of store MUST be 25% of building if not, stop the program, ask the user if they want to continue to analyze another building, and repeat all the questions
sqfeet of warehouse must be 30% of store if not,stop the program, ask the user if they want to continue to analyze another building, and repeat all the questions
use the following functions:
int GetSqfeet(int min, int max)
Used to input all of the square footage amounts. THe input value must be >=min and <=max. The building cannot be processed until the square footage is correct. Note that min and max will be different depending on which value is being input.
int inRange(int sqfeet, int minpercent, int total)
used to verify the secondary conditions. Returns a 1 if its within range or a 0 if its to be rejected.
WHAT I AM HAVING TROUBLE WITH:
a) if I enter for example the sqfeet of the store to be 5000 and the building to be 10000( it is 50% of the building), it still asks me if I want to continue but the percentage is greater than 25.
b) When it does ask me if I want to continue, if I press no, it goes on again.
c) when it repeats, it doesn't start from the beginning (asking the sqfeet of store). It jumps to the sqfeet of the warehouse.
IF U RUN THE PROGRAM, U WILL NOTICE ALL THOSE ERRORS.
I WOULD REALLLLLLYYYY APPRECIATE IF SOMEONE HELPS ME OUT.
# include <stdio.h>
int GetSqfeet();
int inRange();
main()
{
int min=4000;
int max=8000;
int stfeet;
int sqfeet_building;
int minpercent;
int total;
int sqwarehouse;
int range_building;
int range_warehouse;
char answer;
int sqfeet;
clrscr();
do
{
stfeet=GetSqfeet(min,max);
min=stfeet;
max=32000;
sqfeet_building=GetSqfeet(min,max);
total=sqfeet_building;
minpercent=25;
sqfeet=stfeet;
range_building=inRange(sqfeet,minpercent, total);
if (range_building==0)
{
printf("Do you wish to continue"
answer=getche();
}
min=2000;
max=stfeet-1000;
sqwarehouse=GetSqfeet(min,max);
sqfeet=sqwarehouse;
total= stfeet;
minpercent=30;
range_warehouse=inRange(sqfeet, minpercent, total);
if(range_warehouse==0)
{
printf("Do you wish to continue"
answer=getche();
}
} while(answer!='y' || answer!='Y');
return;
}
int GetSqfeet(int min, int max)
{
int sqfeet;
if (max==8000)
{ printf("Enter the square footage of the store: "
scanf("%d",&sqfeet);}
if(max==32000)
{ printf("Enter the square footage of the building: "
scanf("%d",&sqfeet);}
if(min==2000)
{ printf("Enter the square footage of the warehouse: "
scanf("%d",&sqfeet);}
do
{
if((sqfeet<min) || (sqfeet>max))
{
printf("Sorry, that is not within the range:"
scanf("%d",&sqfeet);
}
}while (sqfeet<min || sqfeet>max);
return(sqfeet);
}
int inRange(int sqfeet, int minpercent, int total)
{
int percent;
int range;
percent=(sqfeet/total)*100;
if(percent>=minpercent)
range=1;
else
range=0;
return(range);
}
