Sample Auction bidding application

The below sample auction bidding application is a working program and works exactly as intended. However, it is a good example of code that is not easy to read or maintain. Coding style guidelines and principles for best practices exist to help programmers produce easy to read and maintain applications which is equally important (some would say more so) as program efficiency and application design. Critique the sample program source code provided below and discuss a minimum of seven (7) unique most important best practices and style modifications needed to bring it up to industry acceptable standards for readable and maintainable code and justify why those changes are needed.

 

IMPORTANT

Do not re-write the code!  You must articulate in full sentences the changes you would make using appropriate programming terminology and technical terms.

 

Auction Bidding Application

 

01| #define _CRT_SECURE_NO_WARNINGS

02| #define STARTING_BID 150.00

03| #include <stdio.h>

04| #define INCREMENTS 50.00

05| #define MAX_BIDS 5

06| int main(void){double lastBid = STARTING_BID;int i;

07| printf(“IPC144 Auctionn==============nItem up for bidding: Answers to this midt”

08| “erm test!nStarting bid       : $%.2lfn”, lastBid);

09| for (i = 0; i < MAX_BIDS; i++){int valid;double bid;

10| do {printf(“Make a bid: $”);scanf(“%lf”, &bid);

11| if (!i){valid = bid >= lastBid; if (!valid)printf(“tYou must bid at least $%.2lf!n”, lastBid);}

12| else{valid = bid >= (lastBid + INCREMENTS); if (!valid){printf(“tYou must bid at least $%.2lf!n”, lastBid + INCREMENTS);}}

13| } while (!valid); lastBid = bid;int keepBidding;

14| printf(“tMake another Bid? (no=0): “);scanf(“%d”, &keepBidding);if (!keepBidding) break;

15| }printf(“nWinning bi”

16| “d: $%10.2lfnnn”, lastBid);return 0;}

Sample Execution

 

IPC144 Auction

==============

Item up for bidding: Answers to this midterm test!

Starting bid       : $150.00

Make a bid: $100

You must bid at least $150.00!

Make a bid: $245

Make another Bid? (no=0): 1

Make a bid: $280

You must bid at least $295.00!

Make a bid: $500

Make another Bid? (no=0): 0

 

Winning bid: $    500.00

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *