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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
#include "pch.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int menu(int x) {
cout << "Enter which formula to solve \n";
cout << "1 Cash Flow\n";
cout << "2 Leverage Ratio\n";
cout << "3 Real Return\n";
cout << "4 Percentage Return\n";
cout << "5 Years to Double Investment\n";
cout << "Enter anything else to exit\n";
cin >> x;
return x;
}
double cashflow(double income, double expenses) {
double cf;
cout << setprecision(2) << fixed;
cf = income - expenses;
return cf;
}
double leverageratio(double totaldebt, double totalequity) {
double lr;
cout << setprecision(2) << fixed;
lr = totaldebt / totalequity;
return lr;
}
double RealReturn(double investmentreturn, double inflationrate) {
double rr;
cout << setprecision(2) << fixed;
rr = ((1 + investmentreturn) / (1 + inflationrate) - 1) * 100;
return rr;
}
double PercentageIncrease(double purchaseprice, double marketprice) {
double p;
cout << setprecision(2) << fixed;
p = (marketprice - purchaseprice) / purchaseprice;
return p;
}
double YearstoDouble(double annualinterestrate) {
double di;
cout << setprecision(2) << fixed;
di = 72 / annualinterestrate / 100;
return di;
}
int main()
{
double income, expenses, totaldebt, totalequity, marketprice, purchaseprice, investmentreturn, inflationrate, annualinterstrate;
int x;
cout << "Created by: George Tsolometes \n";
cout << "This program will calculate your Cashflow, Leverage Ratio, Real Return, Percentage Increase, and Years to Double your Income.\n";
cout << "Please enter the following information \n";
cout << "Income: ";
cin >> income;
cout << "\n";
cout << "Expenses: ";
cin >> expenses;
cout << "\n";
cout << "Total debt: ";
cin >> totaldebt;
cout << "\n";
cout << "Total equity: ";
cin >> totalequity;
if (totalequity == 0)
{
while (totalequity == 0) {
cout << "You cannot enter 0 for Total equity.\n";
cout << "Total equity: ";
cin >> totalequity;
}
}
cout << "\n";
cout << "Return on investment: ";
cin >> investmentreturn;
cout << "\n";
cout << "Inflation rate: ";
cin >> inflationrate;
cout << "\n";
cout << "Market price of asset: ";
cin >> marketprice;
cout << "\n";
cout << "Purchase price of asset: ";
cin >> purchaseprice;
if (purchaseprice == 0)
{
while (purchaseprice == 0) {
cout << "You cannot enter 0 as Purchase Price.\n";
cout << "Purchase price: ";
cin >> purchaseprice;
}
}
cout << "\n";
cout << "Annual interst rate: ";
cin >> annualinterstrate;
if (annualinterstrate == 0)
{
while (annualinterstrate == 0) {
cout << "You cannot enter 0 for annual interest rate.\n";
cout << "Annual interst rate: ";
cin >> annualinterstrate;
}
}
cout << "\n";
menu(x);
while (x == 1 || x == 2 || x == 3 || x == 4 || x == 5) {
if (x == 1) {
double cf= cashflow(income, expenses);
cout << endl;
cout << "Your cash flow is " << cf << endl;
cout << endl;
cout << endl;
menu(x);
}
else if (x == 2) {
double lr = leverageratio(totaldebt, totalequity);
cout << endl;
cout << "Your leverage Ratio is " << lr << endl;
cout << endl;
cout << endl;
menu(x);
}
else if (x == 3) {
double rr=RealReturn(investmentreturn, inflationrate);
cout << endl;
cout << "Your Real return is " << rr << endl;
cout << endl;
cout << endl;
menu(x);
}
else if (x == 4) {
double p=PercentageIncrease(purchaseprice, marketprice);
cout << endl;
cout << "Your Percentage increase of the value of your asset is " << p << endl;
cout << endl;
cout << endl;
menu(x);
}
else if (x == 5) {
double di=YearstoDouble(annualinterstrate);
cout << endl;
cout << "Years to double your investment is " << di << endl;
cout << endl;
cout << endl;
menu(x);
}
else;
}
return 0;
}
| |