Implement a c program that prompts the user for the details


Purpose

To practice UDP programming, including the use of the socket, bind, sendto, and recvfrom system calls.

Assignment

Write a C++ program that will validate (imaginary) credit card transaction information by querying to a UDP server. You will be writing the client, and the server's address and port information will be provided to you.

Program

Implement a C++ program that prompts the user for the details of a credit card transaction.

These details include the name of the card holder, the credit card number, the expiration date, and the dollar amount to be authorized.

The card holder name is a string. The card number must be a 15 or 16 digit number. The expiration date is of the form MM/YYYY (eg. 12/2019). The amount will be a number with two digits after the decimal point.

Your program will send the information to a UDP server in a single datagram containing all of the information spec- ified. The server will respond with a single datagram, containing whether the credit card transaction is valid, and an authorization code.

The UDP datagram sent to the server must contain the card number, expiration date, amount, and card holder name in a colon separated list, for example: "6011 1234 4321 1234:12/2016:543.21:John Doe".

UDP Server Details

The details for the UDP Server will be listed in the assignment listing on BlackBoard.

Error Checking

Your program must check whether the name, credit card, expiration date, and amount are well formed. If they are not, prompt the user for them again.

Name can be any string less than 64 characters. Credit card number must be either 15 or 16 digits, with the possibil- ity that spaces may be used between numbers to separate them into groups. The expiration date must be of the form MM/YYYY (obviously MM should be between 01 and 12). The amount can be any number digits followed by a decimal point and then two more digits.

Example Run

% ./assign7
Welcome to the Credit Card transaction verification utility:
Enter card holder name (or quit): John Doe
Enter CC number: 3724 531039 23000
Enter expiration: 10/2016
Enter amount: 12.00
Wed Nov 14 10:34:05 CST 2012: American Express: 3715 199624 21012 is valid: authorization code: 198806 for $12.00 Enter card holder name (or quit): Susan Maloney
Enter CC number: 6011 1234 4321 1234
Enter expiration: 12/16

... expiration date invalid, try again: 12/2014
Enter amount: 1234.56
Wed Nov 14 10:35:45 CST 2012: Discover: 6011 1234 4321 1234 is valid: authorization code: 386489 for $1234.56 Enter card holder name (or quit): Manny Diaz
Enter CC number: 6011432112344321
Enter expiration: 01/2018
Enter amount: forty

... amount invalid, try again: 44
... amount invalid, try again: 44.44
Wed Nov 14 10:36:33 CST 2012: Discover: 6011432112344321: checksum incorrect Enter card holder name (or quit): quit
%

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Implement a c program that prompts the user for the details
Reference No:- TGS02905436

Expected delivery within 24 Hours