Python - This is my code for a baby bitcoin program (question is below the code) balance=int(input("Enter the balance amount in USD: ")) n=int(input("Enter the value of 1 bitcoin in USD: ")) bcoins=0 while True:       print("1. buy 0.5")       print("2. buy 3000")       print("3. sell 0.5")       print("4. sell 3000")       option = int(input("Enter choice:"))      if option==1:         bcoins=bcoins+0.5         balance=balance-0.5*n         print("Balance after buying 0.5 bitcoin")         print("The amount left in USD: ",balance)         print("The number of bitcoins in the wallet: ",bcoins)         print("The USD value of the bitcoins: ",bcoins*n)     elif option==2:         balance=balance-3000         bcoins=bcoins+3000/n         print("Balance after buying bitcoin of worth 3000 USD")         print("The amount left in USD: ",balance)         print("The number of bitcoins in the wallet: ",bcoins)         print("The USD value of the bitcoins: ",bcoins*n)     elif option==3:         bcoins=bcoins-0.5         balance=balance+0.5*n         print("Balance after selling 0.5 bitcoin")         print("The amount left in USD: ",balance)         print("The number of bitcoins in the wallet: ",bcoins)         print("The USD value of the bitcoins: ",bcoins*n)     elif option==4:         bcoins=bcoins-3000/n         balance=balance+3000         print("Balance after selling bitcoin of worth 3000 USD")         print("The amount left in USD: ",balance)         print("The number of bitcoins in the wallet: ",bcoins)         print("The USD value of the bitcoins: ",bcoins*n)     else:         break print("Final Balance") print("The amount left in USD: ",balance) print("The number of bitcoins in the wallet: ",bcoins) print("The USD value of the bitcoins: ",bcoins*n) Problem: Make a class wallet wallet which does the following  1) We need to store the ticker symbol for the coin 2) We need to store how many coins we currently have 3) We also need a “print” method in the class that will print the information out. So, this method will print out the ticker symbol (BTC) for the coin and the number of coins currently in the wallet. 4) We should also have an setter function to add coins to the wallet and a getter function to get the number of coins in the wallet.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 30PE
icon
Related questions
Question

Python - This is my code for a baby bitcoin program (question is below the code)

balance=int(input("Enter the balance amount in USD: "))
n=int(input("Enter the value of 1 bitcoin in USD: "))
bcoins=0
while True:  
    print("1. buy 0.5")  
    print("2. buy 3000")  
    print("3. sell 0.5")  
    print("4. sell 3000")  
    option = int(input("Enter choice:")) 
    if option==1:
        bcoins=bcoins+0.5
        balance=balance-0.5*n
        print("Balance after buying 0.5 bitcoin")
        print("The amount left in USD: ",balance)
        print("The number of bitcoins in the wallet: ",bcoins)
        print("The USD value of the bitcoins: ",bcoins*n)
    elif option==2:
        balance=balance-3000
        bcoins=bcoins+3000/n
        print("Balance after buying bitcoin of worth 3000 USD")
        print("The amount left in USD: ",balance)
        print("The number of bitcoins in the wallet: ",bcoins)
        print("The USD value of the bitcoins: ",bcoins*n)
    elif option==3:
        bcoins=bcoins-0.5
        balance=balance+0.5*n
        print("Balance after selling 0.5 bitcoin")
        print("The amount left in USD: ",balance)
        print("The number of bitcoins in the wallet: ",bcoins)
        print("The USD value of the bitcoins: ",bcoins*n)
    elif option==4:
        bcoins=bcoins-3000/n
        balance=balance+3000
        print("Balance after selling bitcoin of worth 3000 USD")
        print("The amount left in USD: ",balance)
        print("The number of bitcoins in the wallet: ",bcoins)
        print("The USD value of the bitcoins: ",bcoins*n)
    else:
        break
print("Final Balance")
print("The amount left in USD: ",balance)
print("The number of bitcoins in the wallet: ",bcoins)
print("The USD value of the bitcoins: ",bcoins*n)

Problem: Make a class wallet wallet which does the following 

1) We need to store the ticker symbol for the coin 2) We need to store how many coins we currently have 3) We also need a “print” method in the class that will print the information out. So, this method will print out the ticker symbol (BTC) for the coin and the number of coins currently in the wallet. 4) We should also have an setter function to add coins to the wallet and a getter function to get the number of coins in the wallet.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning