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
|
// Cast Time Calculator
#include <iostream>
#include <cmath>
using namespace std;
float computeCastTime(int dexterity, int intelligence, int variable, int base, int fixed);
float computeReductionPercentage(float castTime, int base) ;
void display (int base, float castTime, float reduction);
// This will prompt the user for DEX, INT, Variable Cast Time Reduction (in %), Base Cast Time and Fixed Cast Time Redution (highest modifier)
int main ()
{
// declaration of variables
int dexterity = 0;
int intelligence = 0;
int variable = 0;
int base = 0;
int fixed = 0;
float castTime = 0;
float reduction = 0;
// Prompt
cout << "Please insert DEX: ";
cin >> dexterity;
cout << "\nPlease insert INT: ";
cin >> intelligence;
cout << "\nPlease insert Variable Cast Time Reduction (in %): ";
cin >> variable;
cout << "\nPlease insert Fixed Cast Time Reduction (highest reduction): ";
cin >> fixed;
cout << "\nPlease insert Base Cast Time: ";
cin >> base;
// calculate the total cast time
castTime = computeCastTime(dexterity, intelligence, variable, base, fixed);
// calculate the reduction in %
reduction = computeReductionPercentage(castTime, base);
// display table with results
display(base, castTime, reduction);
// I inserted this so that the program window would not quit right after showing the results of the calculation
cin >> intelligence;
return 0;
}
// calculates the cast time reduction with the following formula:
// castTime = [(1 - SQRT((DEX * 2 + INT) / 530)) * (1 - sum_castReduction/100%) * baseCast * 0.8] + [(1 - max_fixedReduction/100%) * baseCast * 0.2]
float computeCastTime(int dexterity, int intelligence, int variable, int base, int fixed)
{
float castTime = 0;
castTime = (1 - (sqrt (((dexterity * 2) + intelligence) / 530))) * (1 - (variable / 100)) * (base * 0.8) + ((1 - (fixed / 100)) * base * 0.2);
return castTime;
}
// reduction = 1- (castTime / base )
float computeReductionPercentage(float castTime, int base)
{
float reduction = 0;
reduction = (1- (castTime / base)) * 100;
return reduction;
}
// displays the Base time, adjusted base time and reduction %
void display (int base, float castTime, float reduction)
{
cout << "\nBASE TIME\tCAST TIME\tREDUCTION\n";
cout << base << " seconds" << '\t' << castTime << " seconds\t" << reduction << " %\n";
}
|