Dimpy
Refugee
This program will calculate, on average, how many times you need to consume a food item in A18 to increase your max stamina to a certain amount. You can use it on ideone at this link, but it will work better if you compile it and use it at a terminal.
To use it in ideone, you'll have to click the "edit" button, then change the input values in the box below the source code.
Right now it's set to ask for the servings needed to go from 40 food to 140 food, with each serving restoring 10 food.
To use it in ideone, you'll have to click the "edit" button, then change the input values in the box below the source code.
Right now it's set to ask for the servings needed to go from 40 food to 140 food, with each serving restoring 10 food.
Code:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
//You can change these numbers here to change the program:
const int MIN_FOOD = 20;
const float POISION_CHANCE = 0.04;
int main(){
float cur_food, food_restoration, end_food, servings_needed;
cout << "What is the value of your food meter currently?" << endl;
cin >> cur_food;
cout << "How much max stamina does food restore?" << endl;
cin >> food_restoration;
cout << "What level of food meter would you like to end up with?"<< endl;
cin >> end_food;
servings_needed = (
log(1 - POISION_CHANCE*(cur_food - MIN_FOOD)/food_restoration) -
log(1 - POISION_CHANCE*(end_food - MIN_FOOD)/food_restoration)
) / POISION_CHANCE;
cout << "Assuming your food meter can't go below " << MIN_FOOD << " and the food has a "
<< POISION_CHANCE*100 << "% chance of food poision, you will have to eat the food an average "
<< "of " << servings_needed << " times." << endl;
cout << "Without food poisioning, you'd only need to eat " << (end_food - cur_food)/food_restoration <<
" times.\n" ;
return 0;
}