SlideShare a Scribd company logo
Can someone help me find the errors in my codes and fix them... There are mistakes on the raffle
portions. These are my codes so far:
NOTE: Only use void functions if possible, please...
#include
#include
//MAXRAFFLE is the maximum number of available raffle tickets
#define MAXSIZE 100
#define MAXAUCTIONITEMS 1000
#define MAXRAFFLE 1000
//Function prototypes - do not change these
void initRaffle(int raffles[MAXRAFFLE]);
void initAuction(float auction[2][MAXAUCTIONITEMS]);
void buyTickets(float * totalRevenue, int * ticketsSold, int numTickets, float price);
void buyRaffle(float * totalRevenue, int raffles[MAXRAFFLE], int availTickets, int
numTickets, int person);
void bid(float auction[2][MAXAUCTIONITEMS], float bid, int auctionNumber, int person, int
flag);
float awardAuction(float auction[2][MAXAUCTIONITEMS], int auctionNumber);
void awardRaffle(int raffles[MAXRAFFLE], int raffleNumber, int winner);
//Main function
int main() {
FILE * ifp;
char filename[MAXSIZE], event[MAXSIZE], item[MAXSIZE];
float presale, dayOf, totalRevenue = 0;
float auctions[2][MAXAUCTIONITEMS];
int raffles[MAXRAFFLE];
int numPresale, numAuctions, numRaffle, numPrizes, numEvents;
int i, ticketsSold = 0, auctionFlag = 1;
printf("Please enter the input file name. ");
scanf("%s", filename);
ifp = fopen(filename, "r");
fscanf(ifp, "%f%f%d", &presale, &dayOf, &numPresale);
totalRevenue += numPresale * presale;
ticketsSold = numPresale;
fscanf(ifp, "%d", &numAuctions);
fscanf(ifp, "%d%d", &numRaffle, &numPrizes);
fscanf(ifp, "%d", &numEvents);
initRaffle(raffles);
initAuction(auctions);
for (i=0; iauction[0][auctionNumber]) {
auction[0][auctionNumber]=bid;
auction[1][auctionNumber]=person;
printf(" BIDITEM %d ACCEPTED for PERSON %d at %0.2f
DOLLARS",auctionNumber,person, bid);
}
else {
printf(" BIDITEM %d REJECTED for PERSON %d at %0.2f
DOLLARS",auctionNumber,person, bid);
}
}
else
printf(" BIDITEM %d REJECTED for PERSON %d at %0.2f
DOLLARS",auctionNumber,person, bid);
}
// Pre-conditions: auction is an 2D array that holds the current highest bid and the person with
// the highest bid
// auctionNumber is the numerical identifier for the item being awarded
// Post-condition: Returns the value of the highest bid for the auction specified by auction
number
//
// What to do in this function: Check to see if the auction identified by auctionNumber has any
// bids. If so, award the auction to the person with the highest bid. If not, print out that
// there have been no bids for this item. Return the appropriate value to be added to totalRevenue
float awardAuction(float auction[2][MAXAUCTIONITEMS], int auctionNumber) {
if(auction[0][auctionNumber]!= EOF) {
printf(" AUCTION ITEM %d WON BY PERSON %.2f for $%.2f",auctionNumber,
auction[1][auctionNumber],auction[0][auctionNumber]);
return auction[0][auctionNumber];
}
printf(" NO BIDS FOR AUCTION ITEM %d", auctionNumber);
return 0;
}
// Pre-conditions: raffles is an array of all possible raffle tickets
// winner is the winning ticket number
// raffleNumber is the current raffle being held
//
// Post-condition: prints out the numerical identifier of the person who
// holds the winning ticket number
void awardRaffle(int raffles[MAXRAFFLE], int raffleNumber, int winner) {
while (raffles[winner] != EOF) {
printf (" RAFFLE %d WON BY PERSON %d", raffleNumber,raffles[winner]);
break;
}
}
INPUT:
15 25 200
3
100 4
27
BUY TICKET 8
BUY RAFFLE 30 22
BIDITEM 0 2 5
BIDITEM 0 3 20
BUY TICKET 10
BUY RAFFLE 40 209
BUY TICKET 1
BIDITEM 1 17 50
BIDITEM 2 5 30
BUY RAFFLE 26 123
BUY TICKET 3
BIDITEM 1 16 65
BUY RAFFLE 19 211
BIDITEM 1 17 70
BIDITEM 2 200 45
BIDITEM 2 201 54
BUY RAFFLE 1 27
CLOSEAUCTION
BIDITEM 1 100 10000
AWARD RAFFLE 0 13
AWARD RAFFLE 1 98
AWARD RAFFLE 2 30
AWARD RAFFLE 3 85
AWARD AUCTION 0
AWARD AUCTION 1
AWARD AUCTION 2
TOTAL REVENUE
CORRECT OUTPUT:
SOLD TICKETS 200 - 207
RAFFLE TICKETS 0 - 29 given to PERSON 22
BIDITEM 0 ACCEPTED for PERSON 2 at 5.00 DOLLARS
BIDITEM 0 ACCEPTED for PERSON 3 at 20.00 DOLLARS
SOLD TICKETS 208 - 217
RAFFLE TICKETS 30 - 69 given to PERSON 209
SOLD TICKETS 218 - 218
BIDITEM 1 ACCEPTED for PERSON 17 at 50.00 DOLLARS
BIDITEM 2 ACCEPTED for PERSON 5 at 30.00 DOLLARS
RAFFLE TICKETS 70 - 95 given to PERSON 123
SOLD TICKETS 219 - 221
BIDITEM 1 ACCEPTED for PERSON 16 at 65.00 DOLLARS
RAFFLE TICKETS 96 - 99 given to PERSON 211
BIDITEM 1 ACCEPTED for PERSON 17 at 70.00 DOLLARS
BIDITEM 2 ACCEPTED for PERSON 200 at 45.00 DOLLARS
BIDITEM 2 ACCEPTED for PERSON 201 at 54.00 DOLLARS
NO RAFFLE TICKETS given to PERSON 27
CLOSEAUCTION
BIDITEM 1 REJECTED for PERSON 100 at 10000.00 DOLLARS
RAFFLE 0 WON BY PERSON 22
RAFFLE 1 WON BY PERSON 211
RAFFLE 2 WON BY PERSON 209
RAFFLE 3 WON BY PERSON 123
AUCTION ITEM 0 WON BY PERSON 3 for $20.00
AUCTION ITEM 1 WON BY PERSON 17 for $70.00
AUCTION ITEM 2 WON BY PERSON 201 for $54.00
TOTALREVENUE is $3894.00
Solution
#include
#include
//MAXRAFFLE is the maximum number of available raffle tickets
#define MAXSIZE 100
#define MAXAUCTIONITEMS 1000
#define MAXRAFFLE 1000
//Function prototypes - do not change these
void initRaffle(int raffles[MAXRAFFLE]);
void initAuction(float auction[2][MAXAUCTIONITEMS]);
void buyTickets(float * totalRevenue, int * ticketsSold, int numTickets, float price);
void buyRaffle(float * totalRevenue, int raffles[MAXRAFFLE], int availTickets, int
numTickets, int person);
void bid(float auction[2][MAXAUCTIONITEMS], float bid, int auctionNumber, int person, int
flag);
float awardAuction(float auction[2][MAXAUCTIONITEMS], int auctionNumber);
void awardRaffle(int raffles[MAXRAFFLE], int raffleNumber, int winner);
//Main function
int main() {
FILE * ifp;
char filename[MAXSIZE], event[MAXSIZE], item[MAXSIZE];
float presale, dayOf, totalRevenue = 0;
float auctions[2][MAXAUCTIONITEMS];
int raffles[MAXRAFFLE];
int numPresale, numAuctions, numRaffle, numPrizes, numEvents;
int i, ticketsSold = 0, auctionFlag = 1;
printf("Please enter the input file name. ");
scanf("%s", filename);
ifp = fopen(filename, "r");
fscanf(ifp, "%f%f%d", &presale, &dayOf, &numPresale);
totalRevenue += numPresale * presale;
ticketsSold = numPresale;
fscanf(ifp, "%d", &numAuctions);
fscanf(ifp, "%d%d", &numRaffle, &numPrizes);
fscanf(ifp, "%d", &numEvents);
initRaffle(raffles);
initAuction(auctions);
for (i=0; iauction[0][auctionNumber]) {
auction[0][auctionNumber]=bid;
auction[1][auctionNumber]=person;
printf(" BIDITEM %d ACCEPTED for PERSON %d at %0.2f
DOLLARS",auctionNumber,person, bid);
}
else {
printf(" BIDITEM %d REJECTED for PERSON %d at %0.2f
DOLLARS",auctionNumber,person, bid);
}
}
else
printf(" BIDITEM %d REJECTED for PERSON %d at %0.2f
DOLLARS",auctionNumber,person, bid);
}
// Pre-conditions: auction is an 2D array that holds the current highest bid and the person with
// the highest bid
// auctionNumber is the numerical identifier for the item being awarded
// Post-condition: Returns the value of the highest bid for the auction specified by auction
number
//
// What to do in this function: Check to see if the auction identified by auctionNumber has any
// bids. If so, award the auction to the person with the highest bid. If not, print out that
// there have been no bids for this item. Return the appropriate value to be added to totalRevenue
float awardAuction(float auction[2][MAXAUCTIONITEMS], int auctionNumber) {
if(auction[0][auctionNumber]!= EOF) {
printf(" AUCTION ITEM %d WON BY PERSON %.2f for $%.2f",auctionNumber,
auction[1][auctionNumber],auction[0][auctionNumber]);
return auction[0][auctionNumber];
}
printf(" NO BIDS FOR AUCTION ITEM %d", auctionNumber);
return 0;
}
// Pre-conditions: raffles is an array of all possible raffle tickets
// winner is the winning ticket number
// raffleNumber is the current raffle being held
//
// Post-condition: prints out the numerical identifier of the person who
// holds the winning ticket number
void awardRaffle(int raffles[MAXRAFFLE], int raffleNumber, int winner) {
while (raffles[winner] != EOF) {
printf (" RAFFLE %d WON BY PERSON %d", raffleNumber,raffles[winner]);
break;
}
}

More Related Content

More from jeetumordhani

Which of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdfWhich of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdf
jeetumordhani
 
What tissue type has polarity and is avascular What tissue.pdf
What tissue type has polarity and is avascular  What tissue.pdfWhat tissue type has polarity and is avascular  What tissue.pdf
What tissue type has polarity and is avascular What tissue.pdf
jeetumordhani
 
What organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdfWhat organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdf
jeetumordhani
 
What is meant by modular software and why is it important How can t.pdf
What is meant by modular software and why is it important  How can t.pdfWhat is meant by modular software and why is it important  How can t.pdf
What is meant by modular software and why is it important How can t.pdf
jeetumordhani
 
What are the two major steps in biological classification What .pdf
What are the two major steps in biological classification  What .pdfWhat are the two major steps in biological classification  What .pdf
What are the two major steps in biological classification What .pdf
jeetumordhani
 
Tissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdfTissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdf
jeetumordhani
 
The members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdfThe members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdf
jeetumordhani
 
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdfNetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
jeetumordhani
 
Please help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdfPlease help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdf
jeetumordhani
 
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdfNumerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
jeetumordhani
 
My question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfMy question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdf
jeetumordhani
 
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdfJava AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
jeetumordhani
 
Irreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdfIrreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdf
jeetumordhani
 
Inferential statistics is more than descriptive statistics. direct .pdf
Inferential statistics is more  than descriptive statistics.  direct .pdfInferential statistics is more  than descriptive statistics.  direct .pdf
Inferential statistics is more than descriptive statistics. direct .pdf
jeetumordhani
 
If an organism produces two different alleles for a gene, that organ.pdf
If an organism produces two different alleles for a gene, that organ.pdfIf an organism produces two different alleles for a gene, that organ.pdf
If an organism produces two different alleles for a gene, that organ.pdf
jeetumordhani
 
I apologize this 1 question has numerous parts. I didnt want to s.pdf
I apologize this 1 question has numerous parts. I didnt want to s.pdfI apologize this 1 question has numerous parts. I didnt want to s.pdf
I apologize this 1 question has numerous parts. I didnt want to s.pdf
jeetumordhani
 
A sample survey by the Pew internet and American Life Project asked .pdf
A sample survey by the Pew internet and American Life Project asked .pdfA sample survey by the Pew internet and American Life Project asked .pdf
A sample survey by the Pew internet and American Life Project asked .pdf
jeetumordhani
 
8. On January 1, Wismer Corporation declared a $1.50 per share cash d.pdf
8. On January 1, Wismer Corporation declared a $1.50 per share cash d.pdf8. On January 1, Wismer Corporation declared a $1.50 per share cash d.pdf
8. On January 1, Wismer Corporation declared a $1.50 per share cash d.pdf
jeetumordhani
 
Graph one cycle of the following function. y = 5 sin(-2pi x + pi) St.pdf
Graph one cycle of the following function. y = 5 sin(-2pi x + pi)  St.pdfGraph one cycle of the following function. y = 5 sin(-2pi x + pi)  St.pdf
Graph one cycle of the following function. y = 5 sin(-2pi x + pi) St.pdf
jeetumordhani
 
explain why these three properties of water are importantmelting .pdf
explain why these three properties of water are importantmelting .pdfexplain why these three properties of water are importantmelting .pdf
explain why these three properties of water are importantmelting .pdf
jeetumordhani
 

More from jeetumordhani (20)

Which of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdfWhich of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdf
 
What tissue type has polarity and is avascular What tissue.pdf
What tissue type has polarity and is avascular  What tissue.pdfWhat tissue type has polarity and is avascular  What tissue.pdf
What tissue type has polarity and is avascular What tissue.pdf
 
What organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdfWhat organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdf
 
What is meant by modular software and why is it important How can t.pdf
What is meant by modular software and why is it important  How can t.pdfWhat is meant by modular software and why is it important  How can t.pdf
What is meant by modular software and why is it important How can t.pdf
 
What are the two major steps in biological classification What .pdf
What are the two major steps in biological classification  What .pdfWhat are the two major steps in biological classification  What .pdf
What are the two major steps in biological classification What .pdf
 
Tissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdfTissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdf
 
The members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdfThe members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdf
 
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdfNetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
 
Please help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdfPlease help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdf
 
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdfNumerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
 
My question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfMy question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdf
 
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdfJava AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
 
Irreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdfIrreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdf
 
Inferential statistics is more than descriptive statistics. direct .pdf
Inferential statistics is more  than descriptive statistics.  direct .pdfInferential statistics is more  than descriptive statistics.  direct .pdf
Inferential statistics is more than descriptive statistics. direct .pdf
 
If an organism produces two different alleles for a gene, that organ.pdf
If an organism produces two different alleles for a gene, that organ.pdfIf an organism produces two different alleles for a gene, that organ.pdf
If an organism produces two different alleles for a gene, that organ.pdf
 
I apologize this 1 question has numerous parts. I didnt want to s.pdf
I apologize this 1 question has numerous parts. I didnt want to s.pdfI apologize this 1 question has numerous parts. I didnt want to s.pdf
I apologize this 1 question has numerous parts. I didnt want to s.pdf
 
A sample survey by the Pew internet and American Life Project asked .pdf
A sample survey by the Pew internet and American Life Project asked .pdfA sample survey by the Pew internet and American Life Project asked .pdf
A sample survey by the Pew internet and American Life Project asked .pdf
 
8. On January 1, Wismer Corporation declared a $1.50 per share cash d.pdf
8. On January 1, Wismer Corporation declared a $1.50 per share cash d.pdf8. On January 1, Wismer Corporation declared a $1.50 per share cash d.pdf
8. On January 1, Wismer Corporation declared a $1.50 per share cash d.pdf
 
Graph one cycle of the following function. y = 5 sin(-2pi x + pi) St.pdf
Graph one cycle of the following function. y = 5 sin(-2pi x + pi)  St.pdfGraph one cycle of the following function. y = 5 sin(-2pi x + pi)  St.pdf
Graph one cycle of the following function. y = 5 sin(-2pi x + pi) St.pdf
 
explain why these three properties of water are importantmelting .pdf
explain why these three properties of water are importantmelting .pdfexplain why these three properties of water are importantmelting .pdf
explain why these three properties of water are importantmelting .pdf
 

Recently uploaded

Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 

Recently uploaded (20)

Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 

Can someone help me find the errors in my codes and fix them... Ther.pdf

  • 1. Can someone help me find the errors in my codes and fix them... There are mistakes on the raffle portions. These are my codes so far: NOTE: Only use void functions if possible, please... #include #include //MAXRAFFLE is the maximum number of available raffle tickets #define MAXSIZE 100 #define MAXAUCTIONITEMS 1000 #define MAXRAFFLE 1000 //Function prototypes - do not change these void initRaffle(int raffles[MAXRAFFLE]); void initAuction(float auction[2][MAXAUCTIONITEMS]); void buyTickets(float * totalRevenue, int * ticketsSold, int numTickets, float price); void buyRaffle(float * totalRevenue, int raffles[MAXRAFFLE], int availTickets, int numTickets, int person); void bid(float auction[2][MAXAUCTIONITEMS], float bid, int auctionNumber, int person, int flag); float awardAuction(float auction[2][MAXAUCTIONITEMS], int auctionNumber); void awardRaffle(int raffles[MAXRAFFLE], int raffleNumber, int winner); //Main function int main() { FILE * ifp; char filename[MAXSIZE], event[MAXSIZE], item[MAXSIZE]; float presale, dayOf, totalRevenue = 0; float auctions[2][MAXAUCTIONITEMS]; int raffles[MAXRAFFLE]; int numPresale, numAuctions, numRaffle, numPrizes, numEvents; int i, ticketsSold = 0, auctionFlag = 1; printf("Please enter the input file name. "); scanf("%s", filename); ifp = fopen(filename, "r"); fscanf(ifp, "%f%f%d", &presale, &dayOf, &numPresale); totalRevenue += numPresale * presale; ticketsSold = numPresale; fscanf(ifp, "%d", &numAuctions);
  • 2. fscanf(ifp, "%d%d", &numRaffle, &numPrizes); fscanf(ifp, "%d", &numEvents); initRaffle(raffles); initAuction(auctions); for (i=0; iauction[0][auctionNumber]) { auction[0][auctionNumber]=bid; auction[1][auctionNumber]=person; printf(" BIDITEM %d ACCEPTED for PERSON %d at %0.2f DOLLARS",auctionNumber,person, bid); } else { printf(" BIDITEM %d REJECTED for PERSON %d at %0.2f DOLLARS",auctionNumber,person, bid); } } else printf(" BIDITEM %d REJECTED for PERSON %d at %0.2f DOLLARS",auctionNumber,person, bid); } // Pre-conditions: auction is an 2D array that holds the current highest bid and the person with // the highest bid // auctionNumber is the numerical identifier for the item being awarded // Post-condition: Returns the value of the highest bid for the auction specified by auction number // // What to do in this function: Check to see if the auction identified by auctionNumber has any // bids. If so, award the auction to the person with the highest bid. If not, print out that // there have been no bids for this item. Return the appropriate value to be added to totalRevenue float awardAuction(float auction[2][MAXAUCTIONITEMS], int auctionNumber) { if(auction[0][auctionNumber]!= EOF) { printf(" AUCTION ITEM %d WON BY PERSON %.2f for $%.2f",auctionNumber, auction[1][auctionNumber],auction[0][auctionNumber]); return auction[0][auctionNumber]; } printf(" NO BIDS FOR AUCTION ITEM %d", auctionNumber); return 0;
  • 3. } // Pre-conditions: raffles is an array of all possible raffle tickets // winner is the winning ticket number // raffleNumber is the current raffle being held // // Post-condition: prints out the numerical identifier of the person who // holds the winning ticket number void awardRaffle(int raffles[MAXRAFFLE], int raffleNumber, int winner) { while (raffles[winner] != EOF) { printf (" RAFFLE %d WON BY PERSON %d", raffleNumber,raffles[winner]); break; } } INPUT: 15 25 200 3 100 4 27 BUY TICKET 8 BUY RAFFLE 30 22 BIDITEM 0 2 5 BIDITEM 0 3 20 BUY TICKET 10 BUY RAFFLE 40 209 BUY TICKET 1 BIDITEM 1 17 50 BIDITEM 2 5 30 BUY RAFFLE 26 123 BUY TICKET 3 BIDITEM 1 16 65 BUY RAFFLE 19 211 BIDITEM 1 17 70 BIDITEM 2 200 45 BIDITEM 2 201 54 BUY RAFFLE 1 27 CLOSEAUCTION
  • 4. BIDITEM 1 100 10000 AWARD RAFFLE 0 13 AWARD RAFFLE 1 98 AWARD RAFFLE 2 30 AWARD RAFFLE 3 85 AWARD AUCTION 0 AWARD AUCTION 1 AWARD AUCTION 2 TOTAL REVENUE CORRECT OUTPUT: SOLD TICKETS 200 - 207 RAFFLE TICKETS 0 - 29 given to PERSON 22 BIDITEM 0 ACCEPTED for PERSON 2 at 5.00 DOLLARS BIDITEM 0 ACCEPTED for PERSON 3 at 20.00 DOLLARS SOLD TICKETS 208 - 217 RAFFLE TICKETS 30 - 69 given to PERSON 209 SOLD TICKETS 218 - 218 BIDITEM 1 ACCEPTED for PERSON 17 at 50.00 DOLLARS BIDITEM 2 ACCEPTED for PERSON 5 at 30.00 DOLLARS RAFFLE TICKETS 70 - 95 given to PERSON 123 SOLD TICKETS 219 - 221 BIDITEM 1 ACCEPTED for PERSON 16 at 65.00 DOLLARS RAFFLE TICKETS 96 - 99 given to PERSON 211 BIDITEM 1 ACCEPTED for PERSON 17 at 70.00 DOLLARS BIDITEM 2 ACCEPTED for PERSON 200 at 45.00 DOLLARS BIDITEM 2 ACCEPTED for PERSON 201 at 54.00 DOLLARS NO RAFFLE TICKETS given to PERSON 27 CLOSEAUCTION BIDITEM 1 REJECTED for PERSON 100 at 10000.00 DOLLARS RAFFLE 0 WON BY PERSON 22 RAFFLE 1 WON BY PERSON 211 RAFFLE 2 WON BY PERSON 209 RAFFLE 3 WON BY PERSON 123 AUCTION ITEM 0 WON BY PERSON 3 for $20.00 AUCTION ITEM 1 WON BY PERSON 17 for $70.00 AUCTION ITEM 2 WON BY PERSON 201 for $54.00
  • 5. TOTALREVENUE is $3894.00 Solution #include #include //MAXRAFFLE is the maximum number of available raffle tickets #define MAXSIZE 100 #define MAXAUCTIONITEMS 1000 #define MAXRAFFLE 1000 //Function prototypes - do not change these void initRaffle(int raffles[MAXRAFFLE]); void initAuction(float auction[2][MAXAUCTIONITEMS]); void buyTickets(float * totalRevenue, int * ticketsSold, int numTickets, float price); void buyRaffle(float * totalRevenue, int raffles[MAXRAFFLE], int availTickets, int numTickets, int person); void bid(float auction[2][MAXAUCTIONITEMS], float bid, int auctionNumber, int person, int flag); float awardAuction(float auction[2][MAXAUCTIONITEMS], int auctionNumber); void awardRaffle(int raffles[MAXRAFFLE], int raffleNumber, int winner); //Main function int main() { FILE * ifp; char filename[MAXSIZE], event[MAXSIZE], item[MAXSIZE]; float presale, dayOf, totalRevenue = 0; float auctions[2][MAXAUCTIONITEMS]; int raffles[MAXRAFFLE]; int numPresale, numAuctions, numRaffle, numPrizes, numEvents; int i, ticketsSold = 0, auctionFlag = 1; printf("Please enter the input file name. "); scanf("%s", filename);
  • 6. ifp = fopen(filename, "r"); fscanf(ifp, "%f%f%d", &presale, &dayOf, &numPresale); totalRevenue += numPresale * presale; ticketsSold = numPresale; fscanf(ifp, "%d", &numAuctions); fscanf(ifp, "%d%d", &numRaffle, &numPrizes); fscanf(ifp, "%d", &numEvents); initRaffle(raffles); initAuction(auctions); for (i=0; iauction[0][auctionNumber]) { auction[0][auctionNumber]=bid; auction[1][auctionNumber]=person; printf(" BIDITEM %d ACCEPTED for PERSON %d at %0.2f DOLLARS",auctionNumber,person, bid); } else { printf(" BIDITEM %d REJECTED for PERSON %d at %0.2f DOLLARS",auctionNumber,person, bid); } } else printf(" BIDITEM %d REJECTED for PERSON %d at %0.2f DOLLARS",auctionNumber,person, bid); } // Pre-conditions: auction is an 2D array that holds the current highest bid and the person with // the highest bid // auctionNumber is the numerical identifier for the item being awarded // Post-condition: Returns the value of the highest bid for the auction specified by auction number
  • 7. // // What to do in this function: Check to see if the auction identified by auctionNumber has any // bids. If so, award the auction to the person with the highest bid. If not, print out that // there have been no bids for this item. Return the appropriate value to be added to totalRevenue float awardAuction(float auction[2][MAXAUCTIONITEMS], int auctionNumber) { if(auction[0][auctionNumber]!= EOF) { printf(" AUCTION ITEM %d WON BY PERSON %.2f for $%.2f",auctionNumber, auction[1][auctionNumber],auction[0][auctionNumber]); return auction[0][auctionNumber]; } printf(" NO BIDS FOR AUCTION ITEM %d", auctionNumber); return 0; } // Pre-conditions: raffles is an array of all possible raffle tickets // winner is the winning ticket number // raffleNumber is the current raffle being held // // Post-condition: prints out the numerical identifier of the person who // holds the winning ticket number void awardRaffle(int raffles[MAXRAFFLE], int raffleNumber, int winner) { while (raffles[winner] != EOF) { printf (" RAFFLE %d WON BY PERSON %d", raffleNumber,raffles[winner]); break; } }