Welcome! |
|
|
|
|
Site Forum |
|
|
|
|
|
| Formula |
| << Prev Topic | Next Topic >> |
| fudgemaster |
| Posted: 20-June-2010 at 10:32pm | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: 31-January-2010 Location: Canada Posts: 4
|
I'm learning C++ at the moment. I'm just toying around building things, experimenting with code and such. Right now I'm trying to make something that can calculate your chance of surviving a zombie outbreak. I currently have 3 variables (weight, age, speed) and am just trying to figure out a good formula for computing a chance(no greater than 100 or less than 0) of surviving. Here is the unfinished code I have: using namespace std; int main() { //declare variables int weight, speed, age; //prompt for weight cout <<"Hello! if you would like me to calculate your chance of surviving a zombie outbreak please input your weight"; cin >> weight; //make an auto fail for too much weight if(weight>250) cout <<"You have no chance of surviving"; //prompt for speed variable cout << "Please input your speed in MPH"; cin >> speed; //make an auto fail for to low of speed and to much weight(different than auto fail weight) if(speed<10 && weight>200) cout <<"You won't survive."; //prompt age cout <<"Please input your age"; cin>>age; //make an auto fail for age if(age>65) cout<<"I doubt you will survive"; cout << "Here is your chance of surviving a zombie outbreak!"; //this is where the formula comes in return 0; }
Suggestions are appreciated. This is unfinished, which is why I haven't printed the chance which is why I want a good formula.Keep in mind I am just learning it and don't know, so if you can teach me something new that would be nice. Also copying and pasting the code kinda messed with the format of it so it doesn't look very pretty.
|
Online Status: Offline
|
|
| |
| skunkchop |
| Posted: 23-August-2010 at 12:41am | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: 22-August-2010 Posts: 1
|
This is my first post, I'd like to learn C++ too. Here is a
formula you could use, but this assumes that all three factors
are equal. This assumes 30 to be the upper limit of speed, and
20 to be the *best* age. I know this reply is very late, sorry.
Survival % = 66.6 + (speed - (0.017(age-20)^2+33.3) -
weight*8.25)
Needs a bit of tweaking, as it's really harsh.
|
Online Status: Offline
|
|
| |
| 1 User(s) are browsing this topic, 1 Guest(s) and 0 Member(s) |
| 0 Members: |
|
|
|
|
|
If you wish to post a reply to this topic you must first login If you are not already registered you must first register
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum
|
This page was generated in 0.2031 seconds. |