Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Bitcoin We are going to assume that you each have $ 7 5 , 0 0 0 to invest. For this project we assume you

Bitcoin
We are going to assume that you each have $75,000 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 numeric/text based menu gives them choices (ie choose 1 to buy, 2 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 1.0 to buy a bitcoin or sell 0.5 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 30k, and once you get that working change it so that your Get Live function generates a random price for bitcoin (fluctuating from from 25K to 34K 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 25K to 35K.
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 0.5
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 3000
Which would let them by 3K of bitcoin (so you get the current (pseudo) price and figure out how much they can buy for that price)
sell
sell 0.5
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 3000
Which would let them sell 3K worth of their bitcoin at the current price.
balance
They can print their balance. This command must show:
1. Their USD cash balance
2. The number of bitcoins they have in their wallet,
3. 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 1 bitcoin on September 12,201912:32:59. The time should be changing in every transaction since you are showing hours, minutes, seconds.
Lets say that you buy 1.5 bitcoin on September 15th at a market price of $10,000 per coin. Your cash balance would go down from 20K to 5K and the bitcoins in your wallet would go from none, up to 1.5. If you sold half a bitcoin for 6K dollars, your cash balance would go up to 11,000 and your number of bitcoins go down to 1.0.
The history command will print your transactions thus far, for example:
Bought 1 bitcoin on September 12,201912:32:59
Sold 0.5 bitcoin on September 12,201912:33:59
Required Items
Wallet (STORE IN A STRUCT)
For our Wallet struct, we need to store a few things
1) We need to store the ticker symbol for the coin ie BTC
2) We need to store how many coins we currently have
3) We also need to be able to print the information in the structure out. It will print out the ticker symbol (BTC) for the coin and the number of coins currently in the wallet.
4) You should pass the wallet struct to the methods that need it, you 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.
1) It will store the transaction strings just so we have a record of the buy & sell commands. We are going to use ArrayList(Java) Vectors(C++) and then List (Python) for 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.
2) It will be able to print out the transaction history if requested For exam

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions