无法创建用于计算不同车辆的不同停车费用的 if else 程序

Trouble creating an if else program for calculating different parking cost for different vehicles

我无法使这段代码正常工作。我刚刚学习了这个内容(if else 语句),并且必须通过创建一个程序来计算每辆不同车辆的停车费用,从而将其付诸实践。 c 汽车(每小时 2 美元),b 公共汽车(每小时 3 美元),t 卡车(每小时 4 美元)。这是在使用 dev-c++ 编译器的 c 编程中。

感谢所有反馈,提前致谢!

#include <stdio.h>

//declaration
char parkingCharge (int pc);
int pc;
int h, total, c, b, t;
char v;

int main (void)
{ 
//statements

 printf ("Enter type of vehicle (c for car, ");
 printf ("b for bus, or t for truck): ");
 scanf ("%c", &v);
 
 printf ("How long did you park: ");
 scanf ("%d", &h);
 
 total = pc;
 printf ("Your total is: %d", total);

return 0;
}

char parkingCharge (int pc)
{
//statements

 if (v == c){
    pc = 2 * h;
    }
    else if (v == b){
    pc = 3 * h;
    }
    else if (v == t){
    pc = 4 * h;
    }
return total;
}

#include <stdio.h>

//declaration
int parkingCharge (char v, int h);
int h;
char v;

int main (void)
{
//statements

        printf ("Enter type of vehicle (c for car, ");
        printf ("b for bus, or t for truck): ");
        scanf ("%c", &v);

        printf ("How long did you park: ");
        scanf ("%d", &h);
        // You forgot to call the function parkingCharge.
        int total = parkingCharge(v, h);
        printf ("Your total is: %d\n", total);

return 0;
}
// parkingCharge should return an int value and you could pass
// v and h as parameters.
int parkingCharge (char v, int h)
{
    int pc;
    // Remember when you compare a variable with a constant char, you
    // put the constant char value between ''.
    if (v == 'c'){
           pc = 2 * h;
    }
    else if (v == 'b'){
           pc = 3 * h;
    }
    else if (v == 't'){
           pc = 4 * h;
    }
    return pc;
}