Exercise the socket, bind, sendto and recvfrom system calls. Write a C++ program
ID: 3546486 • Letter: E
Question
Exercise the socket, bind, sendto and recvfrom system calls.
Write a C++ program that validates credit card transaction information by querying a UDP server.
Implement a C++ program that prompts the user for credit card transaction detail: name of the card holder, credit card number, expiration date and the amount to be authorized. The card holder name is a string, the card number is a 15 or 16 digit number, the expiration date is of the form mm/yyyy (e.g. 12/2014), and the amount is a number with 2 digits after the decimal point. Your program will send the information to a UDP server in a single datagram. The server will respond with a single datagram. The response contains whether the credit card transaction is valid, and an authorization code. Display the server's response to the user as is. Then the whole dialog will repeat. Execution will stop when "quit" is entered as the card holder name.
The UDP datagram sent to the server must contain the card number, expiration date, amount and card holder name in a colon separated list of words, ex.: "6011 1234 4321 1234:12/2016:543.21:John Doe".
Check whether the name, credit card, expiration date and amount are well formed: if not re-prompt the user.
Name can be any string less than 64 characters. Credit card number is 15 or 16 digits, spaces are allowed to group numbers. Expiration date is of the form mm/yyyy. Amount is of the form digits followed by a decimal point and 2 more digits.
Explanation / Answer
cc
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.