Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Make sure to code ONLY in C in programming language Bitcoin We are going to assume that you each have $ 7 5 , 0
Make sure to code ONLY in C in programming language
Bitcoin
We are going to assume that you each have $to invest. For this project we assume you only are going to be dealing with one currency: bitcoin BTC
Menu
Unless you are a total novice, YOU SHOULD IMPLEMENT A STRING BASED MENU. A numerictext based menu gives them choices ie choose to buy, to sell, etc and they enter the choice they want as a number and you go on from there to get the additional information from them A string basic menu is more like a sentence you type in For example they can type buy to buy a bitcoin or sell to sell half a bitcoin.
Commands
price
This is going to give you the current price of bitcoin every time you call price, it should update the price of bitcoin and show something different each time.
You can either simulate the price of bitcoin: or get the real live price. To simulate, just use a default value initially of kand once you get that working change it so that your Get Live function generates a random price for bitcoin fluctuating from from K to K to simulate current market fluctuations Alternatively, you can get the real price of bitcoin but that task is totally optional its super easy for Python but for Java and C you are on your own for this and would have to download a library that scrapes the price off coinmarketcap or some other website there are various tutorials for it online Because the class is compressed and time is a factor,
its totally acceptable to just simulate the bitcoin price using a random K to K
I think it's easiest to only update the price when they ask for the price. That would mean when they ask for the price you update the price and let them know, and then let the price stick until they ask for the price again. Its nice because you can ask for the price a few times until its something you like.
buy
buy
Would buy you half a bitcoin. Make sure they have enough money to buy what they want to buy. Another acceptable way you could do this would be to have them say
buy
Which would let them by K of bitcoin so you get the current pseudoprice and figure out how much they can buy for that price
sell
sell
Would sell half a bitcoin. Make sure they have enough bitcoin in their wallet to sell what they want to sell. Another option would be to have them say
sell
Which would let them sell K worth of their bitcoin at the current price.
balance
They can print their balance. This command must show:
Their USD cash balance
The number of bitcoins they have in their wallet,
Market Value, call the price function and then print out current price current coin balance
history
They can print the history of their buy and sell transactions out. This will print out the ledger. Make sure that in your transaction strings you stored HOURS MINUTES SECONDS. ie: bought bitcoin on September :: The time should be changing in every transaction since you are showing hours, minutes, seconds.
Lets say that you buy bitcoin on September th at a market price of $per coin. Your cash balance would go down from K to K and the bitcoins in your wallet would go from none, up to If you sold half a bitcoin for K dollars, your cash balance would go up to and your number of bitcoins go down to
The history command will print your transactions thus far, for example:
Bought bitcoin on September ::
Sold bitcoin on September ::
Required Items
Wallet STORE IN A STRUCT
For our Wallet struct, we need to store a few things
We need to store the ticker symbol for the coin ie BTC
We need to store how many coins we currently have
We also need to be able to printthe information in the structure out. It will print out the ticker symbol BTCfor the coin and the number of coins currently in the wallet.
You should pass the wallet struct to the methods that need ityou can think of the buy and sell methods as the setter function to add coins to the wallet and update the cash, and you can think of the getlive function as a getter function to get a simulated live value for bitcoin..
Ledger STORE IN A STRUCT
Inside the structure you can store the history either as an array of strings along with a number n which is the current number of strings in the array that are valid, or as a linked list of strings. I have linked list code in the class notes.
We need a procedure that is going to turn our transactions into a string and store them for our history.
It will store the transaction strings just so we have a record of the buy & sell commands. We are going to use ArrayListJavaVectorsCand then List Pythonfor this. Ie: it will be a list of transaction strings. For C you can store transaction strings in an array or in a linked list either is fine.
It will be able to print
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started