samedi 31 janvier 2015

if-else code for total price won't compile

what is wrong with this im to make c code for total price with one of three ram options.et ramchoices=1or2or3 /this is where I know my problem lies but don't know how to fix it. the compiler needs a one to one relationship. how do I break this up and still show that ramchoice depends on what I pick and those choices affect price./



int main(void) {
/*declare variables*/
float baseprice;
float total;
float ramchoice;
baseprice=1029.48;

/*ramchoice can be 1 or 2 or 3*/

ramchoice=1||ramchoice=2||ramchoice=3;
total=baseprice+ramchoice;

/*initiate variable*/

scanf("%f",&ramchoice);
if("%f" (ramchoice==1))
{
total=baseprice+179.99;
}
else if("%f" ramchoice==2)
{
total=baseprice+94.99;
}
else if("%f" ramchoice==3)
{
total=baseprice+69.99;
}

printf("total is %f",total);

return 0;
}

Aucun commentaire:

Enregistrer un commentaire