• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.
    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Error: object type double is not a function or function pointer

Please remember to use our Code BBCode whenever you are pasting code into a thread/posts. You can read more here: https://codeforum.org/threads/how-to-post-your-code-into-threads.183/
This is an assignment for my class so there are certain requirements I'm following and likely isnt the most efficient program.

Theres an error which isnt letting it run. I attached a screenshot of the error and pasted my code below.

Screen Shot 2020-10-07 at 7.48.53 PM.png

Can anyone help me figure out how to fix it?

Thanks.



#include <stdio.h>


#include <ctype.h>


[COLOR=rgba(255, 255, 255, 0.85)][/COLOR]


//function prototypes


[COLOR=rgba(255, 255, 255, 0.85)][/COLOR]


void[COLOR=rgba(255, 255, 255, 0.85)] Greeting[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]void[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]





void ViewBalance(double balance);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)][/COLOR]


int[COLOR=rgba(255, 255, 255, 0.85)] DisplayMenu[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]void[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]





double OrderPrice(int itemNumber);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


int CheckForEnoughMoney(double balance, double price);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


double Reload(double balance);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)][/COLOR]


int[COLOR=rgba(255, 255, 255, 0.85)] main[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]void[COLOR=rgba(255, 255, 255, 0.85)]) {[/COLOR]





double balanceInMain = 5.00;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] int itemNumInMain;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] double priceInMain = 0.0;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] char again = 'y';[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] int enough;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] double Reload;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] [/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] Greeting[COLOR=rgba(255, 255, 255, 0.85)]();[/COLOR]





while(again == 'y' || again == 'Y' ) {[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


ViewBalance(balanceInMain);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


itemNumInMain = DisplayMenu();[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


priceInMain = OrderPrice(itemNumInMain);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


enough = CheckForEnoughMoney(balanceInMain, priceInMain);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


if(enough == 1) {[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] balanceInMain = balanceInMain - priceInMain;


}


else {[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] balanceInMain = Reload(balanceInMain);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"You need to reload your balance.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


}





ViewBalance(balanceInMain);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] [/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"Would you like to make another purchase? (y or n)\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


scanf(" %c", &again);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] }


return 0;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]}


[/COLOR]


//function definitions


[COLOR=rgba(255, 255, 255, 0.85)][/COLOR]


void[COLOR=rgba(255, 255, 255, 0.85)] Greeting[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]void[COLOR=rgba(255, 255, 255, 0.85)]) {[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\nWelcome to the Coffee Express\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\nWe serve delicious coffee and snacks!\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\nYou will be presented with a list of items and your account balance.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\nPlease select the number for the item you wish to purchase.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\nIf you do not have enough money to cover the purchase, you will be asked to add money to your account.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\nAfter adding money to your account, you will need to reselect the item!\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


}





void ViewBalance(double balance) {[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"Your current balance is %.2f.\n"[COLOR=rgba(255, 255, 255, 0.85)], balance);[/COLOR]


}


[/COLOR]


int[COLOR=rgba(255, 255, 255, 0.85)] DisplayMenu[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]void[COLOR=rgba(255, 255, 255, 0.85)]) {[/COLOR]


int item;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"Here are the coffee and snack options:\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"--------------------------------------"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\n1. Pineapple Smoothie $2.35\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\n2. Blueberry Smoothie $2.35\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\n3. Strawberry Smoothie $4.68\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\n4. Mango Smoothie $4.68\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\n5. Guava Smoothie $3.50\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\n6. Kiwi Smoothie $4.68\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\n7. Apple Smoothie $3.50\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"--------------------------------------"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR][/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\nEnter your selection (1-7): "[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


scanf("%d", &item);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] return item;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]}





double OrderPrice(int itemNumber) {[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


double price = 0.0;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]switch(itemNumber) {[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] case[COLOR=rgba(255, 255, 255, 0.85)] [/COLOR]1[COLOR=rgba(255, 255, 255, 0.85)]: [/COLOR]printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"You selected Pineapple Smoothie. The price is $2.35.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


price = 2.35;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] break;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] case[COLOR=rgba(255, 255, 255, 0.85)] [/COLOR]2[COLOR=rgba(255, 255, 255, 0.85)]: [/COLOR]printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"You selected Blueberry Smoothie. The prce is $2.35.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


price = 2.35;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] break;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] case[COLOR=rgba(255, 255, 255, 0.85)] [/COLOR]3[COLOR=rgba(255, 255, 255, 0.85)]: [/COLOR]printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"You selected Strawberry Smoothie. The price is $4.68.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


price = 4.68;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] break;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] case[COLOR=rgba(255, 255, 255, 0.85)] [/COLOR]4[COLOR=rgba(255, 255, 255, 0.85)]: [/COLOR]printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"You selected Mango Smoothie. The price is $4.68.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


price = 4.68;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] break;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] case[COLOR=rgba(255, 255, 255, 0.85)] [/COLOR]5[COLOR=rgba(255, 255, 255, 0.85)]: [/COLOR]printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"You selected Guava Smoothie. The price is $3.50.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


price = 3.50;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] break;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] case[COLOR=rgba(255, 255, 255, 0.85)] [/COLOR]6[COLOR=rgba(255, 255, 255, 0.85)]: [/COLOR]printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"You selected Kiwi Smoothie. The price is $4.50.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


price = 4.50;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] break;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] case[COLOR=rgba(255, 255, 255, 0.85)] [/COLOR]7[COLOR=rgba(255, 255, 255, 0.85)]: [/COLOR]printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"You selected Apple Smoothie. The price is $3.25.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


price = 3.25;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] default[COLOR=rgba(255, 255, 255, 0.85)]: [/COLOR]printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"That is an invalid selection.\n"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


price = 0.0;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] }


return price;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]}





int CheckForEnoughMoney(double balance, double price) {[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] if(balance >= price) {[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


return 1;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] }


else {[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]


return 0;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] }


}[/COLOR]


double[COLOR=rgba(255, 255, 255, 0.85)] Reload[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]double[COLOR=rgba(255, 255, 255, 0.85)] balance)[/COLOR]


{


double amount;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] printf[COLOR=rgba(255, 255, 255, 0.85)]([/COLOR]"\nEnter the amount you want to add:"[COLOR=rgba(255, 255, 255, 0.85)]);[/COLOR]


scanf("%lf", &amount);[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)] return amount + balance;[/COLOR]


[COLOR=rgba(255, 255, 255, 0.85)]}





[/COLOR]
 

Krusty the Senile

Active Coder
Reformatted the code below. After I did that, I noticed you have a variable Reload defined in the main() function, as well as a function called Reload(). Rename the variable to something different - the compiler is trying to resolve the variable as a function.

Formatted code:

C:
#include <stdio.h>
#include <ctype.h>

//function prototypes

void Greeting(void);
void ViewBalance(double balance);
int DisplayMenu(void);
double OrderPrice(int itemNumber);
int CheckForEnoughMoney(double balance, double price);
double Reload(double balance);

int main(void) {
    double balanceInMain = 5.00;
    int itemNumInMain;
    double priceInMain = 0.0;
    char again = 'y';
    int enough;
    double Reload;

    Greeting();
    while(again == 'y' || again == 'Y' ) {
        ViewBalance(balanceInMain);
        itemNumInMain = DisplayMenu();
        priceInMain = OrderPrice(itemNumInMain);
        enough = CheckForEnoughMoney(balanceInMain, priceInMain);

        if(enough == 1) {
            balanceInMain = balanceInMain - priceInMain;
        }
        else {
            balanceInMain = Reload(balanceInMain);
            printf("You need to reload your balance.\n");
        }

        ViewBalance(balanceInMain);
        printf("Would you like to make another purchase? (y or n)\n");
        scanf(" %c", &again);
    }

    return 0;
}

//function definitions

void Greeting(void) {
    printf("\nWelcome to the Coffee Express\n");
    printf("\nWe serve delicious coffee and snacks!\n");
    printf("\nYou will be presented with a list of items and your account balance.\n");
    printf("\nPlease select the number for the item you wish to purchase.\n");
    printf("\nIf you do not have enough money to cover the purchase, you will be asked to add money to your account.\n");
    printf("\nAfter adding money to your account, you will need to reselect the item!\n");
}

void ViewBalance(double balance) {
    printf("Your current balance is %.2f.\n", balance);
}

int DisplayMenu(void) {
    int item;

    printf("Here are the coffee and snack options:\n");
    printf("--------------------------------------");
    printf("\n1. Pineapple Smoothie $2.35\n");
    printf("\n2. Blueberry Smoothie $2.35\n");
    printf("\n3. Strawberry Smoothie $4.68\n");
    printf("\n4. Mango Smoothie $4.68\n");
    printf("\n5. Guava Smoothie $3.50\n");
    printf("\n6. Kiwi Smoothie $4.68\n");
    printf("\n7. Apple Smoothie $3.50\n");
    printf("--------------------------------------");
    printf("\nEnter your selection (1-7): ");

    scanf("%d", &item);

    return item;
}

double OrderPrice(int itemNumber) {
    double price = 0.0;

    switch(itemNumber) {
        case 1: printf("You selected Pineapple Smoothie. The price is $2.35.\n");
                price = 2.35;
                break;

        case 2: printf("You selected Blueberry Smoothie. The prce is $2.35.\n");
                price = 2.35;
                break;


        case 3: printf("You selected Strawberry Smoothie. The price is $4.68.\n");
                price = 4.68;
                break;

        case 4: printf("You selected Mango Smoothie. The price is $4.68.\n");
                price = 4.68;
                break;

        case 5: printf("You selected Guava Smoothie. The price is $3.50.\n");
                price = 3.50;
                break;

        case 6: printf("You selected Kiwi Smoothie. The price is $4.50.\n");
                price = 4.50;
                break;

        case 7: printf("You selected Apple Smoothie. The price is $3.25.\n");
                price = 3.25;

        default: printf("That is an invalid selection.\n");
                 price = 0.0;
    }

    return price;
}

int CheckForEnoughMoney(double balance, double price) {
    if(balance >= price) {
        return 1;
    }
    else {
        return 0;
    }
}


double Reload(double balance)
{
    double amount;
    printf("\nEnter the amount you want to add:");
    scanf("%lf", &amount);
    return amount + balance;
}
 
Top Bottom