HELP! i have to deliver this work tomorow!

I'm making a program that calculates the sales of electrical energy but it is not working properly! can someone help me? this work is for tomorrow! grateful.
# include
# include <stdlib.h>
int main () {
int CC, consumption;
float rate, VF, I, VP;
printf ("Enter a consumer class, which can take the value 1, 2 or 3 \ n");
scanf ("% d", & CC);
if (CC! = 1 && CC! && CC = 2! = 3) {
printf ("ERROR! \ n");
system ("PAUSE");
return (1);}
if (CC == 1) {
rate = 0.5;}
if (CC == 2) {
rate = 0.8;}
if (CC == 3) {
rate = 1.0;}
printf ("Enter how many KWH were consumed \ n");
scanf ("% d, & consumption");
* VF = consumption*rate;
I = 0.3 * FV;
VP = VF + I;
printf ("The amount payable is:% f", VP);
system ("PAUSE");
return (0);
}
What do you mean by "it isn't working"? Are you getting compile errors? Not giving you the right answer? Or???

Some obvious errors:
1) You need to #include <stdio.h>

2) The following statement is just wrong
 
if (CC! = 1 && CC! && CC = 2! = 3) 


3) What are you trying to do with the following statement? It looks like you're trying to deference a pointer.
 
* VF = consumption*rate;


4) Is this supposed to reference VF?
 
I = 0.3 * FV;


5) You can't put a space between \ and n.
1
2
printf ("ERROR! \ n");
printf ("Enter how many KWH were consumed \ n");


6) The following printf statement needs a \n
7) You also can't put a space between the % and the f.
 
printf ("The amount payable is:% f", VP);

'm not getting the right answer! put wrong here ... actually the right is
# include <stdio.h
# include <stdlib.h>
int main () {
int CC, consumption;
float rate, VF, I, VP;
printf ("Enter a consumer class, which can take the value 1, 2 or 3 \n");
scanf ("% d", & CC);
if (CC! = 1 && CC!= 2 && CC!=3) {
printf ("ERROR! \n");
system ("PAUSE");
return (1);}
if (CC == 1) {
rate = 0.5;}
if (CC == 2) {
rate = 0.8;}
if (CC == 3) {
rate = 1.0;}
printf ("Enter how many KWH were consumed \n");
scanf ("% d, & consumption");
VF = consumption*rate;
I = 0.3 * VF;
VP = VF + I;
printf ("The amount payable is:% f", VP);
system ("PAUSE");
return (0);
Last edited on
Please put your code in the source code brackets. The <> button to the right. Makes it much easier to read.
Topic archived. No new replies allowed.