Question

(The program should be executed on C language) 1. Bob conducts a silent auction of 30rare...

(The program should be executed on C language)

1. Bob conducts a silent auction of 30rare optimum Maserati MC12s. Bob’s program will keep track of 49 different bidders.

•A valid bid prices must be >= 2,000,000

•A bidder can put in multiple bids

•A bidder can win at most one car

•Only the highest 30 bids are recorded

•The price of a newer bid is always higher than all previous bids

•All bid prices must be different.

Input:  Read from stdioand each line will have the bidder name and the bidding price:

•Richard_Branson1900123

•John_Rockefeller2000005

•Larry_Page2000100

•Richard_Branson2000110

Output: the program prints out the names of the 30bidders who have the HIGHEST30 bid prices (from highest to lowest) with the total maximum revenue obtained from the auction.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answer to the above question is given below :

The C code to find the top 30 bidders and the total revenue is given below :
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
  
   int n=0;
   char *name[10000]; // for storing the name of bidders
   for(int i=0;i<50;i++)
       name[i] = (char )malloc(sizeof(char)); // memory allocation to store all names
   long long amount,bid[10000]; // array to store bid value
   printf("Type -1 to exit\n"); // to exit bidding
   while(1)
   {
       scanf("%s",name[n]); // entering name
       if(strcmp(name[n],"-1") == 0) // if -1 entered then break
           break;
       scanf("%lld",&amount); // if valid name then take bid value as input.
       if(amount < 200000) // valid bid >= 200000
           continue;
       if(n>0 && amount <= bid[n-1]) // valid bid is in increasing order
           continue;
       bid[n++] = amount; // if valid bid then store and increase the value of n.
   }
  
   int count = 0; // for counting the top 30 bidders
   long long total_sum = 0; // to calculate the total revenue
   printf("Top 30 bidders are :\n");
   for(int i=n-1;i>=0;i--) // run loop from last to get the higher bid first.
   {
       int flag = 1;
       for(int j=i+1;j<n;j++) // checking that the current bidder has already made a purchase or not.
       {
           if(strcmp(name[i],name[j]) == 0)
           {
               flag = 0;
               break;
           }
       }
       if(flag == 1) // flag=1 means current bidder has not made any purchase yet.
       {
           count++; // increase bidder count as 1.
           total_sum += bid[i]; // adding the bid value
           printf("%s - %lld\n",name[i],bid[i]); // printing the bidder and bid detail
       }
       if(count == 30) // break when count reached to 30
           break;
   }
   printf("Total Revenue is : %lld\n",total_sum);
   return 0;
}

Note : -1 shows the termination of the bidding.

Screenshot of the running code is given below :

If the answer helped please upvote, it means a lot and for any query please comment.

Add a comment
Know the answer?
Add Answer to:
(The program should be executed on C language) 1. Bob conducts a silent auction of 30rare...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Suppose you are a bidder in a first-price sealed-bid auction for a single object, where players...

    Suppose you are a bidder in a first-price sealed-bid auction for a single object, where players submit bids simultaneously and the player who bid the highest wins the object and must pay his/her bid. Assume there are two other bidders, so this is a three-player game. You do not observe the valuations of the other bidders, but assume that you believe their valuations are identically and independently distributed according to a uniform distribution on the interval from 0 to 20....

  • 2. Second Price Auction& Google Search Auction (18 points) A. (11 points) There are two bidders,...

    2. Second Price Auction& Google Search Auction (18 points) A. (11 points) There are two bidders, bidder 1 and bidder 2, bidding for one object. Their valuations of the object (vi, v2) are simultaneously submit their bidding prices (b, by The one with the higher price wins the auction and pays the loser's price, the second highest price. (In answering the questions below, no detailed explanations are needed and you just need to directly give the conclusion.) independent. Each one...

  • Question 1: eBay's Recommendation It is hard to imagine that anyone is not familiar with eBay,...

    Question 1: eBay's Recommendation It is hard to imagine that anyone is not familiar with eBay, the most popular auction website by far. In a typical eBay auction a good is placed for sale, and each bidder places a 'proxy bid' which eBay keeps in memory. If you enter a proxy highest bid, then your bid is ignored. If, however, it is higher, then the current bid increases up to one increment (say, 1 cent) above the second highest proxy...

  • Project 4: ER-Diagram and DBDL (25 Points) Database Design Language (DBDL) Use Visio or Word to...

    Project 4: ER-Diagram and DBDL (25 Points) Database Design Language (DBDL) Use Visio or Word to create the model. The correct syntax must be used. Remember to list out all alternate keys, secondary keys, and foreign keys. Entity Relationship Diagram (ERD) Draw the data model for the situation using LucidChart, Microsoft Visio, Word or other ERD Drawing Program. When drawing the objects, be sure to use the correct shapes, and syntax. Example: Entity is a rectangle box, and the name...

  • PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create...

    PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT