Lessons 18 c# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Lessons 18 c#

Please help me to solve this practice from lesson 18 We are making a program for auction with a maximum bid set. The count of bids is variable. Write a program to take the maximum bid as input, then take all bids from auction participants until the maximum bid is exceeded. The program should output the corresponding message with the winning bid. Sample Input 1600 800 1300 1700 Sample Output Sold: 1700 Explanation The first input represents the maximum bid, followed by the bids offered from all participants. The last participant suggested a bid (1700) which is above the maximum (1600) and won the auction. Thus, that bid is outputted. Hint In order to make continuous input acceptance you need to use while(true) condition. For example, this

28th Sep 2021, 7:05 AM
Tim Tam
3 Answers
+ 4
All you need to Take another input inside loop and use the if statement to check whether it's greater than maxBid or not. You can use break statement to stop the loop.
28th Sep 2021, 7:23 AM
Simba
Simba - avatar
+ 1
Thanks Simba
28th Sep 2021, 9:13 AM
Tim Tam