Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

program this 1 ) It will store the transaction strings just so we have a record of the buy & sell commands. We are going

program this 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 example it might print out the following transaction strings::
Bought
1
bitcoin on September
1
2
,
2
0
1
9
1
2
:
3
2
:
5
9
Sold
0
.
5
bitcoin on September
1
2
,
2
0
1
9
1
2
:
3
3
:
5
9
3
)
You may want to have a method to add a transaction string. It takes as a parameter a string and adds it to the transaction list.
(
Once you know how many they bought or sold, there are functions available to get the current date and time. So from those pieces of data you make a string using string concatenation and then you send the string to the ledger
s
add
method and it adds it to the ledger
)
Date
(
IMPLEMENT AS A FUNCTION
)
This function will call the library routines to get the current date. It will have a function in it that returns that date as a string. We need this for our transaction history
GetLive
(
IMPLEMENT AS A FUNCTION
)
This is going to fetch the current live value of bitcoin.
(
Most of you will fake it by generating a random number between
2
5
and
3
5
k
.
Getting the live value in Python is easy, for other languages you can find libraries to use however it is ok to just approximate the value by generating a random number for example between
2
5
and
3
5
k
.
Putting it all together
Your program will create an instance of the above. Additionally, it will create a variable to track your USD
(
you can use a double or float
)
.
You can keep your USD variable out in the main, or you can tuck it in with the wallet struction.
Then the program will go into a loop. It will print their menu options and ask what command they want to do
.
They can buy, sell, ask for the balance, the price, and print the history, and exit when they want to
.
When you buy coins your US dollars go down and the number of bitcoins in your wallet goes up accordingly. When you sell coins your US balance goes up and the number of coins you have goes down. The variable that stores your actual cash
/
US dollars
(
USD
)
does not really need to be in the wallet structure if you don
t want it to be
.
It can be just a double called USD.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

Students also viewed these Databases questions