Old bitcoin calculator I made.

I had to come up with a project for my C++ class so I made a bitcoin calculator. I know by looking at the programming and the functionality it is pretty lame, but I had fun making it and wanted to share it on the forums.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//sam Stafford Bitcoin Mining Calculator	
#include <iostream>
#include <string>
using namespace std;
//functions
float block_reward(float);
float currency_day(float,float,float);// finds amount of bitcoins and dollars made per day.
float electricity_cost(float,float,float);
float total_profit(float,float,float,float);
string show(int);

// calculated variables
float totalprofit;
float coinsperblock;
float coinsperday;
float dollarsperday;
float electricitycost;
float totalgains;
float totallosses;
//input variables
float difficulty;
float total_blocks;
float market_price;
float hardware_cost;
float power_usage;
float electricity;
float mining_speed;
float time;
int enthusiasm;

int main(){
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout<<"This application can be used to determine whether bitcoin mining is viable over a certain length of time.Enter the values as prompted."<<endl;
cout<<endl;
cout<<"What is the current bitcoin mining difficulty?\nThis can be found at: http://blockchain.info/blocks" <<endl;
cin>> difficulty;
cout<<endl;
cout<<"What is the current number of total blocks mined by the community?\nThis can be found at:http://blockchain.info/blocks" <<endl;
cin>> total_blocks;
cout<<endl;
cout<<"What is the current Market Price for Bitcoins?\nCan be found at:http://blockchain.info/blocks" <<endl;
cin>>market_price;
cout<<endl;
cout<<"What was the cost of Hardware in your mining rig? " <<endl;
cin>> hardware_cost;
cout<<endl;
cout<<"What is the Power Usage on your machine?\nCheck PSU wattage." <<endl;
cin>>power_usage;
cout<<endl;
cout<<"What is your cost of electricity at your current residency?\nIn United States it is typically .11 USD/kWh" <<endl;
cin>> electricity;
cout<<endl;
cout<<"What is your current mining speed in Mhash/s?\nThis can be found: https://en.bitcoin.it/wiki/Mining_hardware_comparison" <<endl;
cin>> mining_speed;
cout<<endl;
cout<<"How long do you plan on running your rig in time days?" <<endl;
cin>> time;
cout<<endl;
block_reward(total_blocks);
currency_day (coinsperblock,mining_speed,market_price);
electricity_cost(electricity, power_usage,time);
total_profit(dollarsperday,electricitycost,hardware_cost,time);

cout<<" "<<endl;
cout<<"Profits: "<<endl;
cout<<"Total Gains"<<"\t"<<"Total Losses"<<"\t"<<"Total Profit" <<endl;
cout<<totalgains<<"\t\t"<<totallosses<<"\t\t"<<totalprofit<<endl;
cout<<endl;
cout<<"Additional Information: "<<endl;
cout <<"Time (days)"<<"\tDollars/day"<<"\tCoins/day"<<"\tHardware Cost"<<"\tElectricity Cost"<<endl;
cout << time << "\t\t"<<dollarsperday <<"\t\t"<< coinsperday <<"\t\t"<<hardware_cost<<"\t\t"<<electricitycost<<endl;
cout<<" "<<endl;
cout<<"On a scale from 1 to 5, how much effort, enthusiasm and hardwork do you plan on investing?"<<endl;
cout<<"(One being the lowest, five being the highest)"<<endl;
cin>>enthusiasm;
cout<< show(enthusiasm);
}

float block_reward(float total_blocks){ // changed this just to what divide coins perday by.

float i;
for(i=0;105,000>!total_blocks<!210000;i++){
	total_blocks/2;
	i++;
}
if (i!=0){
coinsperblock= 50/(2*i);

}
else{
	coinsperblock=50;
return coinsperblock;
}
}
float currency_day(float coinsperblock,float mining_speed,float marketprice){
	coinsperday = (20.1162*mining_speed*coinsperblock)/difficulty;
	dollarsperday = coinsperday*market_price;
	return coinsperday, dollarsperday;
	}
float electricity_cost(float electricity,float power_usage,float time){
	float costperhour;
	costperhour = electricity*(power_usage/1000);
	electricitycost = costperhour*24*time;
	return electricitycost;
}
float total_profit(float dollarsperday,float electricitycost, float hardware_cost,float time){
	totalgains=(dollarsperday*time);
	totallosses=(electricitycost+hardware_cost);
	totalprofit= totalgains-totallosses;
	return totalgains,totallosses,totalprofit;
}
string show(int enthusiasm){
switch(enthusiasm)
{
	case 1:
	{		
	return "It would be best if you gave up now.\n";
	break;
	
	}
case 2:
	{	
			return "You won't make any money with that spirit.\n";
			break;
	}

case 3:
{		
	return "You have a shot to make some cash.\n";
			break;
	}

case 4:
	{	
			return "With confidence like that, you should have a steady income in no time.\n";
			break;
	}

case 5:
	{	
			return "Looks like you are ready to make the big bucks!\n";
			break;
	}

}

}
So many globals :O
Yeah haha. I looked at that when I was done and was just like meh, I will just hand it in.
Topic archived. No new replies allowed.