联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2018-07-30 03:47


Develop a program in C and upload it into your Arduino Mega 2560 board to implement a simple credit card management system. The Arduino Mega 2560 should interact with the user via the Serial Monitor. The program should do as described below. An example is given after the following description.

1.Display the following information on the Serial Monitor: Unit code and title, your name, your student ID.

2.Set Pins 14 to 21 of Arduino Mega board as inputs. Enable the internal pull-up resistor for each of these pins.

3.Prompt the user to select one of the following options:

1.Add New Account//assume we will have maximum 10 accounts

2.Account Information//Name, Card Number, Expiry Date, Password

3.Deposit Funds//Based on Card Number

4.Withdraw Funds//Based on Card Number

4.Receive the user’s selection via the Serial Monitor, e.g. 1, 2, … or 4.

5.Depending on the selected option, prompt the user to enter relevant input information, and then implement the stated action/display as follows:


For 1:

Full Name://First Name Last Name, max 30 characters

// show full name to user

Credit Card Number://6 digits entered, show digits to user

//Receive the digits as a string of 6 characters

Expiry Date://4 digits, show digits to user

//Receive digits as a string of 4 characters

Password://User selects an 8-bit password by connecting

//some of the Pins 14 to 21 of Arduino to GND

// with jumper wires, the rest would be VCC due

// to pull-up resistors, then presses Enter key

// show the 8-bit code to user

/*Store the entered information, plus $0 for account balance, into appropriate variables*/

For 2:


Credit Card Number://6 digits entered, show digits to user

//Receive the digits as a string of 6 characters

Password://User selects an 8-bit password by connecting

//some of the Pins 14 to 21 of Arduino to GND

// with jumper wires, the rest would be VCC due

// to pull-up resistors, then presses Enter key

// show the 8-bit code to user


/*Compare 6-digit Card Number with the Card Numbers stored in the system.

If a match is found, then check the entered password against the stored password. Display the following if passwords matched. Otherwise, display “Account not found!” */


Full Name: …// First Name Last Name

Credit Card Number: …//6 digits

Expiry Date: …//4 digits

Account Balance: …//Latest account balance



For 3:


Credit Card Number://6 digits entered, show digits to user

//Receive the digits as a string of 6 characters Deposit Amount: $//user enters an integer amount and system

// shows amount to user


/*Compare 6-digit Card Number with the Card Numbers stored in the system.

If a match is found, add amount to the current account balance amount stored in a relevant integer variable. */


For 4:


Credit Card Number://6 digits entered, show digits to user

//Receive the digits as a string of 6 characters Withdraw Amount: $//user enters an integer amount and system

// show amount to user


/*Compare 6-digit Card Number with the Card Numbers stored in the system.

If a match is found, subtract entered amount from the current account balance amount stored in an integer variable. */



6.Go to Step 3

Example for “1. Add New Account”


----------------------------------------------------------------------

Full Name: John Smith Credit Card Number: 497823

Expiry Date: 1220//December 2020

Password: 01011111//User connects Pins14,16 to GND (01011111=0x5F), presses Enter key

----------------------------------------------------------------------

Account added

----------------------------------------------------------------------

Example for “3. Deposit Funds”


----------------------------------------------------------------------

Credit Card Number: 497823 Deposit Amount: $50

----------------------------------------------------------------------

Amount deposited

----------------------------------------------------------------------

Example for “2. Account Information”


----------------------------------------------------------------------

Credit Card Number: 497823

Password: 01011111//User connects Pins14,16 to GND (01011111=0x5F), presses Enter key

----------------------------------------------------------------------

Full Name: John Smith Credit Card Number: 497823 Expiry Date: 1220

Account Balance: $50

----------------------------------------------------------------------

Example for “2. Account Information”


----------------------------------------------------------------------

Credit Card Number: 555111

Password: 01011111//User connects Pins14,16 to GND (01011111=0x5F), presses Enter key

----------------------------------------------------------------------

Account not found!

----------------------------------------------------------------------

The use of high level Arduino Functions (see http://arduino.cc/en/Reference/HomePage, under Functions) is not permitted. Significant marks will be deducted if any of the functions is used. Native C functions are however permitted.

Goals

1.Write code to implement a user friendly and neat user interface to interact with the user.

2.Write code to perform implement and execute the specified functions.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp