Hi guys, I have a problem with this question, where the amount is constantly $0 and at the end if the user enters Y/N it just closes without saying "Transaction Completed/Cancelled".

Any tips on how to fix it?

Thanks

#include<stdio.h>
#include <iostream>
#include<math.h>

int main()
{
	int numofbees;
	float price = 5;
	char query;
	char Y;
	char N;

	printf("How many bees would you like to purchase?\n");
		scanf("%d", &numofbees);
		printf("That will be $%d, confirm? (Y/N)\n", price*numofbees);
		scanf("%c", &query);
		if(query == Y)
			printf("Transaction completed.");
		else if(query == N)
		        printf("Transaction cancelled.");

		getchar();
		getchar();
		return 0;
	}

Y and N have no values if you want to check if the user used either then compare it to the letter itself e.g.

if(query == 'Y')

also

printf("That will be $%d, confirm? (Y/N)\n", price*numofbees);

price is a float, &d is used for integers use %f

Problem #1:
After your first scanf() , the ENTER you typed is still in the input buffer, waiting for the next input. Your second scanf() reads that ENTER. So the value is not 'y' nor 'n', so no message.

Problem #2:
And, as zeroliken said, the variables Y and N have no value. You want characters, not variables.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.