OK, i changed it a bit now:
Code:
#include <stdio.h>
#include <math.h>
int main(void)
{
double amt[7];
int a,b,c,d,e,f,g,menu;
amt[0]=0.0,amt[1]=0.0,amt[2]=0.0,amt[3]=0.0,amt[4]=0.0,amt[5]=0.0,amt[6]=0.0;
while(1) {
printf("==========\nCurrent Co2 Emission:\n");
printf("Total Co2 Emission is: %f", amt[0]+amt[1]+amt[2]+amt[3]+amt[4]+amt[5]+amt[6]);
printf("\n\n=================\nPlease choose a fuel activity from below:\n\n1 - Petrol (litres)\n2 - Oil (litres)\n3 - Coal (kg)\n4 - Wood (kg)\n5 - Electricity (kWhr)\n6 - Natural Gas (kWhr)\n7 - Air Travel (miles)\n8 - Quit\n\n\t");
scanf("%d",&menu);
switch (menu) {
case '1': printf("How much Petrol? (litres)");
scanf(" %d",&a);
amt[0] += a * 2.3;
break;
case '2': printf("How much Oil? (litres)");
scanf(" %d",&b);
amt[1] += b * 2.3;
break;
case '3': printf("How much Coal? (kg)");
scanf(" %d",&a);
amt[2] += c * 2.3;
break;
case '4': printf("How much Wood (kg)");
scanf(" %d",&a);
amt[3] += d * 2.3;
break;
case '5': printf("How much Electricity (kWhr)");
scanf(" %d",&a);
amt[4] += e * 2.3;
break;
case '6': printf("How much Natural Gas (kWhr)");
scanf(" %d",&a);
amt[5] += f * 2.3;
break;
case '7': printf("How much Air Travel (Miles)");
scanf(" %d",&a);
amt[6] += g * 2.3;
break;
case '8': break;
}
if (menu != 1 || menu != 2 || menu != 3 || menu != 4 || menu != 5 || menu != 6 || menu != 7 || menu != 8);
printf("You did not enter a valid menu option");
}
getchar();
return 0;
}
However it doesnt ask the user 'how much petrol' etc, i type a number and it displays the number and nothing else.
I also get the warnings:
Empty body in an if statement,
c might be uninitialized,
d """""""""""""""""""""
e
f
g