I'm trying to write a program to calculate meat and the prices and stuff but the program comes up with <null> embarrassingly enough I have spent over 8 hours trying to do this
Code:
#include <stdio.h>#include <stdlib.h>
#define beef 1 /* multiplication factor of beef*/
#define chicken 1.5 /*factor of chicken*/
#define pork 2 /* factor of pork*/
#define s1 0.5 /* state1 is close to expiry*/
#define s2 1 /*state2 is frozen storage*/
#define s3 1.5 /*state3 is fresh*/
int main(int argc, char *argv[])
{
float amt = 0; /*amount of meat*/
char st = 0; /*state of meat*/
char meat = 0; /*type of meat*/
float price = 0; /*total price*/
printf ("This program calculates price of meat. \n");
printf ("\n Please enter type of meat ( beef, chicken, pork):");
fflush (stdin);
scanf ("%s",&meat);
if ((meat != beef) || (meat != chicken) || (meat != pork))
price, "NA";
printf ("\n Please enter state of meat(s1, s2, s3):");
fflush (stdin);
scanf ("%s",&st);
if ((st != s1) || (st != s2) || (st != s3))
price, "NA";
printf ("\n Please enter quantity of grams of meat (0 - 2000):");
fflush (stdin);
scanf ("%d",&amt);
if ((amt < 0 ) || (amt > 2000))
price, "NA";
else if (amt >= 1500)
price = (meat*st)*8;
else if (amt >= 1000)
price = (meat*st)*6;
else if (amt >= 500)
price = (meat*st)*4;
else
price = (meat*st)*2;
printf( "\n the price is: %s", price);
if (price [0] == 'N', price [1] == 'A')
printf ("Variable is not recognized, please use provided variables");
system("PAUSE");
return 0;
}