Compare Word With Words Inside Multidimensional Array on C [on hold]
First to say i am learning to code on C at university so this is all relatively new for me! I have been trying to make a program that makes discounts depending on the car brand you're buying, let's say a Toyota costs $100 plus taxes $107 but it'll have a 8% discount on it's final price.
I made a multidimensional array where i saved all the brand names with discounts available, when the user enters the car that is going to be sold and it's raw price the program calculates the price with taxes plus a the mentioned discount. it seems like when the program tries to compare the brand name submitted by the user with the ones stored inside the multidimensional array it crashes.
here is the code that i made:
printf("Car Brand\n");
scanf("%s", &br);
printf("Car Cost\n");
scanf("%f", &pricec);
preciov = pricec + ( pricec * 0.07 );
if ( strcmp ( brand[0][0], br ) == 0 ) {
disc = ( pricec * 0.08 );
total = ( pricec - disc );
} else if ( strcmp ( brand[1][0], br ) == 0 ) {
disc = ( pricec * 0.10);
total = ( pricec - disc );
} else if ( strcmp ( brand[2][0], br ) == 0 ) {
disc = ( pricec * 0.12 );
total = ( pricec - disc );
} else if ( strcmp ( brand[3][0], pricec ) == 0 ) {
disc = ( pricec * 0.15 );
total = ( pricec - deic );
} else {
disc = 0;
total = pricec;
}
printf ("\nRaw Car Cost %s ------ $%.2f\nDiscounts--- $%.2f\n Total ---------- $%.2f\n\n", br, pricec, disc, total);
getchar();
system("pause");
return 0;
}