函数`float calcSize(int,int,int,int)'的参数太少了。

时间:2014-03-22 08:23:19

标签: c

它一直告诉我在我的float calcSize()函数中运行的参数太少,即使我在其中发送了所有4个变量。我的另一个问题是,我的计划有意义吗?

#include <stdio.h>
#include <conio.h>
#define PAINT 350.00

//Function Prototype
void displayInstructions();
float calcSize(int , int , int , int );
float calcPaint(float);
float calcCost(float, float);
void displayTotals(float, float, float);

int main()
{
    // Variables
    int l , w , d, win ;
    float s;
    float p;
    float cP = 32.00;
    float c ;  

 displayInstructions();
 //Getting variables
    printf("Please enter the number of heights in feet");
     scanf("%d",&l);
    printf("Please enter the number of width");
     scanf("%d",&w);
    printf("Please enter the number of doors");
     scanf("%d",&d);
    printf("Please enter the number of windows");
     scanf("%d",&win);

    calcSize(l , w , d , win);
     calcSize() = s;
    calcPaint(s);
     calcPaint() = p;
    calcCost(p, cP);
      calcCost() = c;              
    displayTotals(s , p , c);       

getch();
return 0;
}

//Display function    
void displayInstructions()
{
     Printf("Welcome to the Green Paint Calculator!");
     Printf("\nEnter the height and width of the room (in feet)");
     Printf("\nand the number of doors and windows."); 
     Printf("This program will then calculate how many cans of paint needed"); 
     Printf("\n(based on 2 coats of paint).It will then calculate the cost"); 
     Printf("\nbased on the charge per gallon entered");       
}
//Calcsize function
float calcSize(int l, int w, int d, int win)
{    
     float area, areaDoors, areaWindows;

     area = (l + w) * 2 * 8.0;
     areaDoors = d * 20;
     areaWindows = win * 15;

     area -= areaDoors + areaWindows;     
     return area;
}

//calcPaint function
float calcPaint(float s)
{
      float galPaint;

      galPaint = s / PAINT * 2;
      return galPaint;
}
//calccost function
float calcCost(float p, float cP)
{
      return p * cP;
}
//Display total function
void displayTotals(float s, float p, flaot c)
{
     printf("\n\nSize of room in square feet: %.2f", s);
     printf("\nNumber of gallons needed: %.2f", p);
     printf("\nTotal cost to paint room: %.2f", c);
}

2 个答案:

答案 0 :(得分:1)

你的节目没有任何意义。我不知道你想用calcSize() = s;做什么。我认为它应该像

s = calcSize(l , w , d , win); 

如果您想将函数的返回值赋给s

答案 1 :(得分:0)

你的代码错了.....     calcSize(l,w,d,win);      calcSize()= s;     calcPaint(一个或多个);      calcPaint()= p;     calcCost(p,cP);       calcCost()= c;
    displayTotals(s,p,c);

使用如下......

s= calcSize(l , w , d , win);
// calcSize() = s;[this line shows you too-few arguments] and lvalue error
p= calcPaint(s);
 //calcPaint() = p;[this line shows you too-few arguments]and lvalue error
c=calcCost(p, cP);
  //calcCost() = c; [this line shows you too-few arguments]and lvalue error             
displayTotals(s , p , c);