Just a few of the mistakes in here.
I added tolower to fix your bracket issue of malformed bracket separation
between && and || after I fixed the malformed bracket separation.
your use of default in your switch is wrong, plus it has no break in it.
read red comment inside of your code.
Code:
//#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
//#include <conio.h>
#include <ctype.h> // tolower
//#include <math.h> // not needed, you're not calling any math functions
#define MOULD 3500
int main()
{
int quantity, test=0;
float cost, discount, Dis_Prize, total, GCT;
char ComName[12], Fname[10], Lname[15], PHnum[17], choice, code;
printf("APPAREL CODE APPAREL TYPE MINIMUM ORDER QUANTITY COST OF ITEM \n");
printf(" T T-SHIRT 25 $320 \n");
printf(" B BAGS 10 $250 \n");
printf(" C CAPS 25 $170 \n");
printf("\nENTER CODE CORRESPONDING TO THE TYPE OF APPAREL DESIRED: ");
fflush(stdin);
scanf(" %c",&code);
switch(code)
{
case 'T':
case 't':
printf("ENTER QUANTITY OF T-SHIRT YOU WISH TO ORDER: ");
fflush(stdin);
scanf(" %d", &quantity);
printf("DO YOU WANT ANY DESIGN? Y/N: ");
fflush(stdin);
scanf(" %c", &choice); // whence you answer this question
system("cls"); // it no longer has any reason to stay in the switch
// other than finishing your totaling of values in your block of code
// in this case part, then your if staments fail as well for being able to
// to check that answer so it then drops
// down to your if(test==1) check then finishes just like
// it is being told to. your code works, because it is doing
// what you are telling it to do, it is your logic that needs fixing to make
// code do what you want it to do. Not what you're presently telling it to do.
if ((quantity>=25) && (quantity<50) && (tolower(choice) =='y') ) //|| (choice=='Y'))
{
cost = quantity * 320 + MOULD; // here choice = y so I get to see no choice of design to select same.
discount = 0.0;
GCT = 0.165 * cost;
total = cost + GCT;
test= test+1;
}
else if ((quantity>50) && (tolower(choice) =='y') ) // || (choice=='Y'))
{
cost = quantity * 320 + MOULD;
discount = cost * 0.05;
Dis_Prize = cost - discount;
GCT = 0.165 * Dis_Prize;
total = Dis_Prize + GCT;
test= test+1;
}
else if ((quantity>=25) && (quantity<50) && (tolower(choice) =='n') ) //|| (choice=='n'))
{
cost = quantity * 320;
discount = 0.0;
GCT = 0.165 * cost;
total = cost + GCT;
test= test+1;
}
else if((quantity>50) && (tolower(choice) =='n') ) // || (choice=='N'))
{
cost = quantity * 320;
discount = cost * 0.05;
Dis_Prize = cost - discount;
GCT = 0.165 * Dis_Prize;
total = Dis_Prize + GCT;
test= test+1;
}
else if ( (choice!='y') && (choice!='Y') && (tolower(choice) !='n') ) // !='N') && (choice!='n'))
{
printf("THE OPTIONS FOR DESIGN IS EITHER YES(Y) OR NO (N)\n");
}
else if (quantity < 25)
printf("YOU ARE NOT ALLOWED TO ORDER LESS THAN 25 SHIRTS\n");
break; // BREAKS HERE
case 'B':
case 'b':
printf("ENTER QUANTITY OF BAGS YOU WISH TO ORDER: ");
scanf("%d",&quantity);
system("cls");
if(quantity>=10 && quantity<50)
{
cost = quantity * 250 + 3500;
discount = 0.0;
GCT = 0.165 * cost;
total = cost - GCT;
}
else if (quantity>50)
{
cost = quantity * 250 + 3500;
discount = cost * 0.05;
Dis_Prize = cost - discount;
GCT = 0.165 * Dis_Prize;
total = Dis_Prize - GCT;
}
else
printf("You are NOT allowed to order less than 10 BAGS\n");
break;
case 'C':
case 'c':
printf("ENTER QUANTITY OF CAPS YOU WISH TO ORDER: ");
scanf("%d",&quantity);
system("cls");
if(quantity>=25 && quantity<50)
{
cost = quantity * 170 + 3500;
discount = 0.0;
GCT = 0.165 * cost;
total = cost - GCT;
}
else if (quantity>50)
{
cost = quantity * 170 + 3500;
discount = cost * 0.05;
Dis_Prize = cost - discount;
GCT = 0.165 * Dis_Prize;
total = Dis_Prize - GCT;
}
else
printf("You are NOT allowed to order less than 25 CAPS\n");
break;
default:
printf("INVALID INPUT\n");
}
if(test==1)
{
printf("\nSUMMARY OF OUR TRANSACTION\n");
printf("APPAREL CODE YOU SELECTED: %c\n", code);
printf("ORDER QUANTITY: %d\n", quantity);
printf("CUSTOMER'S NAME: %s %s\n", Fname, Lname);
printf("CUSTOMER'S COMPANY: %s\n", ComName);
printf("CUSTOMER'S PHONE NUMBER: %s\n", PHnum);
printf("VALUE OF ORDER IS: $%f\n", cost);
printf("DISCOUNT: $%f\n", discount);
printf("GCT: $%f\n",GCT);
printf("TOTAL AMMOUNT TO BE PAID IS: $%f\n", total);
}
else
printf("GOODBYE");
return 0;
}
results:
Code:
userx@slackwhere:~/bin
$ ./quantity
APPAREL CODE APPAREL TYPE MINIMUM ORDER QUANTITY COST OF ITEM
T T-SHIRT 25 $320
B BAGS 10 $250
C CAPS 25 $170
ENTER CODE CORRESPONDING TO THE TYPE OF APPAREL DESIRED: t
ENTER QUANTITY OF T-SHIRT YOU WISH TO ORDER: 34
DO YOU WANT ANY DESIGN? Y/N: y
sh: cls: command not found
SUMMARY OF OUR TRANSACTION
APPAREL CODE YOU SELECTED: t
ORDER QUANTITY: 34
CUSTOMER'S NAME:
CUSTOMER'S COMPANY:
CUSTOMER'S PHONE NUMBER:
VALUE OF ORDER IS: $14380.000000
DISCOUNT: $0.000000
GCT: $2372.699951
TOTAL AMMOUNT TO BE PAID IS: $16752.699219
It'd might help if you write down your logic first in the steps of what you need to take place first then write your code to reflect same. logic board,
Code:
make menus
print menu(s)
get input
if input good
do this
if bad do that / ask again // requirement of a loop to get it to go back to asking again?
(which logic could look like this)
get input
if ( input != to what I want)
ask again
else
store input, then
go to next line (operation to get more input)
next line:
get more input
if ( input != to what I want)
ask again
else
store input then
go to next line (operation to get more input)
next line (operation to get more input)
//maybe
check to see if user wants to change mind,
if ( input == changed mine)
start all over again
else
total, print out totals.
what would be the default behavior, will their be any default behavior to determine how to
use the default check in a switch, do I even need a switch? if yes, how many?
what is required to get that done, a loop maybe? if yes how many and what type or types of loops would I need?
how many variables do I need?
what types of data will I be using, int char and any variation of same?
something like that perhaps.
the using of the key words continue and break in a loop, they are their for a reason. using break to get out of a loop when the conditions are present
is valid coding.