Hi everyone, I could really use your help trying to figure this out! I've had no problem understanding everything leading up to functions (printf, scanf, calculations, validation, etc.) but I cannot figure out how to do these functions for the life of me!

I was just finally able to get rid of all the bugs and run the program, but it only gets to "enter a quantity greater than or equal to 0" and no matter what number I enter it goes to the error and loops back.


Here is the assignment and code:


The program will track the amount and price of raffle tickets sold, and then add to a grand total. The price per raffle ticket has to be equal to or greater than $5.00, amount of tickets has to be equal to or greater than 0.

I've planned the program out to look something like this at the end (aside from changes in character strings)--

WELCOME TO THE RAFFLE!

Enter price per raffle ticket (must be at least $5.00):

Enter number of raffle tickets (must be at least 0):

Number of tickets ---------->
Price per ticket ------------->
Total amount due ---------->

Would you like to make another raffle ticket purchase? (y/n)

/* If y, loop back to beginning. If n, proceed to next. */

Grand total of all tickets ---->

/*==============================================*/


My code:

Code:
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

void heading(void);
void quanerror(double min);
void costerror(double min);
double getfloat(char prompt[], double min);
double getdouble(char prompt[], double min);
double total(double ticketquan, double ticketcost);
void show(double ticketquan, double ticketcost, double tickettotal, double grandtotal);
int contyn(char msg[]);

int main()
{
	double quanmin, ticketquan, ticketcost, tickettotal, costmin, grandtotal;
	double multtotal;
	
	char choice;

	quanmin = 0;
	costmin = 5;

do
{
heading();
	ticketquan = getdouble("quantity", quanmin);
	ticketcost = getfloat("price", costmin);
	tickettotal= total(ticketquan, ticketcost);
	grandtotal+= tickettotal;
	choice  = contyn("\nWould you like to purchase more raffle tickets?");
	show(ticketquan, ticketcost, tickettotal, grandtotal);
	
	}
while (choice == 'y' || choice == 'Y');
return 0;
}
/* ================================================================ */

void heading()
{
	system("cls");  // Linux/Unix use: system("clear");
	printf("WELCOME TO THE RAFFLE!\n");
	return;
}
/* ================================================================ */
double getdouble(char item[], double min)
{
   int err;
   double ticketquan;
   min = 0;
do
   {
   printf("\nEnter a ticket %s greater than or equal to %d: ", item, min);
   scanf_s("%d%*c", &ticketquan);
   err = (ticketquan < min);
   if (err) quanerror(min);
   }
while (err);
return (ticketquan);
}
/* ================================================================ */
double getfloat(char item[], double min)
{
   int err;
   double ticketcost;
   min = 5;
do
   {
   printf("\nEnter a ticket %s greater than or equal to %.2lf: ", item, min);
   scanf_s("%lf%*c", &ticketcost);
   err = (ticketcost < min);
   if (err) quanerror(min);
   }
while (err);
return (ticketcost);
}
/* ================================================================ */
void quanerror(double min)
{

printf("\nOut of range.  Enter a quantity of %d or higher. ", min);
return;
}
/* ================================================================ */
void costerror(double min)
{

printf("\nOut of range.  Enter a price of %.2lf or higher. ", min);
return;
}
/* ================================================================ */
double total(double ticketquan, double ticketcost)
{
return (ticketquan * ticketcost);
}
/* ================================================================ */
void show(double ticketquan, double ticketcost, double tickettotal, double grandtotal)
{
	printf("\nAmount of tickets: %d", ticketquan);
	printf("\nPrice per ticket : %.2lf", ticketcost);
	printf("\nTotal amount due : %.2lf", tickettotal);
	printf("\nGrand total of all purchases: %.2lf", grandtotal);
	printf("\n\n");
	printf("Press Enter to continue ");
getchar();
}
/* ================================================================ */
int contyn(char msg[])
{
	int c;
printf("%s (Y/N):", msg);
c = getchar();
c = toupper(c);
return c;
}
/* ================================================================ */