- #1
TheDemx27
Gold Member
- 169
- 13
Just upgraded my internet, and I want to upgrade my download calculator along with it, since I find many programs give me shaky and inaccurate download times. I rigged my network so I can switch between my slow speed and fast speed DSL. The problem is the "if / else" statement at the end of main. No matter whether I give it a "f" or a "s" it executes whatever is under the "if"; in this case "FastSpeed();"
Any responses are appreciated.
Any responses are appreciated.
Code:
#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
float MB;
int Time;
int Time2;
int Time3;
string speed;
int GetInput(){
cout << "Insert Megabytes" << endl;
cin >> MB;
return MB;
}
static int FastSpeed(){
Time = MB * 1.62;
Time2 = Time / 60;
Time3 = Time2 / 60;
cout << endl << "It will take " << Time2 << " minutes to download this." << " (" << Time3 << "hours)" << endl;
return 0;
}
static int SlowSpeed(){
Time = MB * 10;
Time2 = Time / 60;
Time3 = Time2 / 60;
cout << endl << "It will take " << Time2 << " minutes to download this." << " (" << Time3 << "hours)" << endl;
return 0;
}
int main(){
system ("title Demx's Download Calculator");
system ("color a");
cout << "------------------------------------------" << endl;
cout << "WELCOME TO DEMX's DOWNLOAD CALCULATOR v1.0" << endl;
cout << "------------------------------------------" << endl << endl;
GetInput();
cout << "FAST or SLOW net? (f/s)";
cin >> speed;
if (speed == "f" || "F"){
FastSpeed();
}
else if (speed == "s" || "S"){
SlowSpeed();
}
else {
cout << "Please enter a valid choice:";
}
system ("PAUSE");
return 0;
}