Professional Software Engineering | |
Test the real thingsToday,because of multicultural issues,many peoples are entering Europe and US who are newbies in programming.This is a snare to quality demands in Software Engineering. I am graduated german software engineer offering systematic,high level software engineering at reasonable rates.Contact me at +4915172972526 or [email protected] to receive high quality software Below you find a freeware Python program for calculation of cryptocurrency wallets' total value.Have a look at it to get convinced of my software development capabilities. # crypto wallet sum calculator, 2022 by Juergen Josef Schmidt # class holding a table of cryptocurrency prices class Rates: #name of cryptocurrency cnames = [] #value in US cent cvalues = [] #number of rates stored numRates = 0 def __init__ (self): self.cnames = [] self.cvalues =[] self.numRates = 0 def addRate(self,cname,cval): self.cnames.append(cname) self.cvalues.append(cval) self.numRates += 1 #write a table of cryptocurrency prices to a file def writeRates(self): try: datei = open("rates.txt", "w") except FileNotFoundError: print("Could not open rate file for writing") return False for i in range(self.numRates): datei.write(self.cnames[i]+" "+str(self.cvalues[i])+"\r\n") datei.close() #add a rate from the file def addRateFromFile(self,pair): pairList = pair.split(' ') #print(pairList[0]) #print(pairList[1]) self.addRate(pairList[0],pairList[1]) #read the table of cryptocurrency prices from a file def readRates(self): datei = open("rates.txt","r") except: return False allRates = datei.read() datei.close() rateList = allRates.split("\n") rateList = rateList[0:len(rateList)-1] for r in range(len(rateList)): self.addRateFromFile(rateList[r]) return True #add a new cryptocurrency and its rate from user input def addRate(self,name,price): self.cnames.append(name) self.cvalues.append(price) self.numRates += 1 class Deposits: #name of cryptocurrency cnames = [] #number of deposited satoshi cdeps = [] #number of rates stored numDeposits = 0 def __init__ (self): self.cnames = [] self.cdeps =[] self.numDeposits = 0 def addDeposit(self,cname,cdep): self.cnames.append(cname) self.cdeps.append(cdep) self.numDeposits += 1 #write a table of cryptocurrency deposits to a file def writeDeposits(self): datei = open("deposits.txt","w") for i in range(self.numDeposits): datei.write(self.cnames[i]+" "+str(self.cdeps[i])+"\r\n") datei.close() #add a deposit from the file def addDepositFromFile(self,pair): pairList = pair.split(' ') #print(pairList[0]) #print(pairList[1]) self.addDeposit(pairList[0],pairList[1]) #read the table of crytocurrency deposits from a file def readDeposits(self): try: datei = open("deposits.txt","r") except: return False allDeposits = datei.read() datei.close() depositList = allDeposits.split("\n") depositList = depositList[0:len(depositList)-1] for d in range(len(depositList)): self.addDepositFromFile(depositList[d]) print("Number of deposits read from File : "+str(len(depositList))) return True #add a new cryptocurrency and its deposit from user input def addDeposit(self,name,deposit): self.cnames.append(name) self.cdeps.append(deposit) self.numDeposits += 1 # class holding the values of all cryptocurrency assets with name and value in USD class ValueTable: # the names of the cryptocurrencies cnames = [] # their values in USD cent,each value in this list is a long natural number cvals = [] # the number of name-value pairs stored numValues = 0 def __init__ (self): cnames = [] cvals = [] numValues = 0 def addCryptVal(self,name,val): self.cnames.append(name) self.cvals.append(val) self.numValues += 1 def writeValueTable(valTab): datei = open("ValTab.csv","w") for i in range(0,valTab.numValues): datei.write(valTab.cnames[i]+","+str(valTab.cvals[i]/10000000000)+"\r\n") datei.close() def calculateSum(r,d,valTab): sum=0 if(valTab==True): currTable = ValueTable() for dn in d.cnames: if dn in r.cnames: print("Found deposit ") for i in range(len(r.cnames)): if (dn==r.cnames[i]): print("Found price "+dn) sum += int(d.cdeps[i])*int(r.cvalues[i]) print("Sum : "+str(sum)) if (valTab==True): currVal = int(d.cdeps[i])*int(r.cvalues[i]) currTable.addCryptVal(r.cnames[i],currVal) print("Sum of cryptocurrency deposits :"+str(sum/10000000000)+" USD") if(valTab==True): writeValueTable(currTable) processing = True cptable = Rates() cdtable = Deposits() #cvtable.addDeposit("Bitcoin",100) #cvtable.addDeposit("Litecoin",1000000) #cvtable.writeDeposits() #print(cvtable.numRates) #print(cvtable.cnames[1]+" "+cvtable.cvalues[1]) readRatesSuccessFully = cptable.readRates() readDepositsSuccessFully = cdtable.readDeposits() #print ("Files read : "+str(readRatesSuccessFully and readDepositsSucessFully)) # the crypto wallets sumup program's main loop while processing: userInput = input("User command : ").upper() # x : exit the program if (userInput=="X"): processing=False continue # a : add a cryptocurrency and its initial price and its initial deposit elif(userInput=="A"): ccname = input("Name of new cryptocurrency : ").upper() iprice = input("Initial price of cryptocurrency : ").upper() ideposit = input("Initial deposit of new cryptocurrency : ").upper() cptable.addRate(ccname,iprice) print(cptable.cnames[cptable.numRates-1]+" "+cptable.cvalues[cptable.numRates-1]) print(cptable.numRates) cdtable.addDeposit(ccname,ideposit) print(cptable.cnames[cdtable.numDeposits-1]+" "+cdtable.cdeps[cdtable.numDeposits-1]) print(cdtable.numDeposits) #changes are written back to the file immediately cptable.writeRates() cdtable.writeDeposits() # remove all walet data from permanent storage elif(userInput=="D"): os.remove("rates.txt") os.remove("deposits.txt") cptable = Rates() cdtable = Deposits() # recalculate value of all wallets elif(userInput=="R"): calculateSum(cptable,cdtable,False) #recalculate value of all wallets,dumping a value table CSV file elif(userInput=="T"): calculateSum(cptable,cdtable,True) # change rate of a cryptocurrency elif(userInput=="C"): ccname = input("Name of cyrptocurrency : ").upper() iprice = input("Price of cryptocurrency : ").upper() for i in cptable.cnames: if(i==ccname): idx = cptable.cnames.index(ccname) cptable.cvalues[idx]=iprice break cptable.writeRates() # change rate of a cryptocurrency elif(userInput=="P"): ccname = input("Name of cyrptocurrency : ").upper() ideposit = input("Amount of deposit : ").upper() for i in cptable.cnames: if(i==ccname): idx = cptable.cnames.index(ccname) cdtable.cdeps[idx]=ideposit break cdtable.writeDeposits() if you are interested in seeing a C program look here | |
![]() |