SlideShare a Scribd company logo
#include <iostream>
#include <cmath>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
class FinancialCalculator
{
private:
double FV;
double roi;
double ATR;
double presentvalue, rate;
int period;
public:
FinancialCalculator();
FinancialCalculator(double PV, double r, int n);
double acidTestRatio(double i, double j, double k);
double futureValue(double x, double y, int z);
double RateofInterest(double a, double b, double c);
string getDate(int date);
double min(double[], int);
double max(double[], int);
double getPV();
double getr();
int getn();
int searchList(const double[], int, double);
};
FinancialCalculator::FinancialCalculator()
{
cout << "Please enter the following" << endl;
}
double FinancialCalculator::futureValue(double PV, double r, int n)
{
double FV;
FV = PV * pow((1 + r), n);
return FV;
}
double FinancialCalculator::RateofInterest(double tr, double texp, double CoI)
{
double roi;
roi = ((tr - texp) - CoI) / CoI;
return roi;
}
double FinancialCalculator::acidTestRatio(double CA, double Inv, double CL)
{
double ATR;
ATR = (CA - Inv) / CL;
return ATR;
}
int FinancialCalculator::searchList(const double revenue[], int ARRAY_SIZE, double
lowest)
{
int index = 0;
int position = -1;
bool found = false;
while (index < ARRAY_SIZE && !found)
{
if (revenue[index] == lowest)
{
found = true;
position = index;
}
index++;
}
return position;
}
string FinancialCalculator::getDate(int date)
{
string dates;
if (date < 31) {
dates = "January " + to_string(date + 1) + " 2015";
}
else if (date < 59)
dates = "February " + to_string(date - 31 + 1) + " 2015";
else if (date < 90)
dates = "March " + to_string(date - 59 + 1) + " 2015";
else if (date < 120)
dates = "April " + to_string(date - 90 + 1) + " 2015";
else if (date < 151)
dates = "May " + to_string(date - 120 + 1) + " 2015";
else if (date < 181)
dates = "June " + to_string(date - 151 + 1) + " 2015";
else if (date < 212)
dates = "July " + to_string(date - 181 + 1) + " 2015";
else if (date < 243)
dates = "August " + to_string(date - 212 + 1) + " 2015";
else if (date < 273)
dates = "September " + to_string(date - 243 + 1) + " 2015";
else if (date < 304)
dates = "October " + to_string(date - 273 + 1) + " 2015";
else if (date < 334)
dates = "November " + to_string(date - 304 + 1) + " 2015";
else
dates = "December " + to_string(date - 334 + 1) + " 2015";
return dates;
}
double FinancialCalculator::min(double revenue[], int ARRAY_SIZE)
{
int count; double lowest;
lowest = revenue[0];
for (count = 1; count < ARRAY_SIZE; count++)
{
if (revenue[count] < lowest)
lowest = revenue[count];
}
return lowest;
}
double FinancialCalculator::max(double expenses[], int ARRAY_SIZE)
{
int count; double highest;
highest = expenses[0];
for (count = 1; count < ARRAY_SIZE; count++)
{
if (expenses[count] > highest)
highest = expenses[count];
}
return highest;
}
FinancialCalculator::FinancialCalculator(double PV, double r, int n)
{
presentvalue = PV;
rate = r;
period = n;
}
double FinancialCalculator::getPV()
{
return presentvalue;
}
double FinancialCalculator::getr()
{
return rate;
}
int FinancialCalculator::getn()
{
return period;
}
class FVc : public FinancialCalculator
{
private:
int times;
double FVC;
public:
FVc(double PV, double r, int n, int t) : FinancialCalculator(PV, r, n)
{
times = t;
setFVC(PV, r, n, t);
}
void setFVC(double PV, double r, int n, int t)
{
FVC = PV * pow((1 + (r / t)), (n*t));
}
double getFVC()
{
return FVC;
}
};
int main()
{
const int AcidTestRatio = 1, FutureValue = 2, RateOfInterest = 3, CompanyX = 4,
Quit = 5;
int choice;
double CA, Inv, CL, ATR;
int t, n;
double PV, r, FV;
double CoI, tr, texp, roi;
do
{
cout << "MENU OPTIONS:n";
cout << "1. AcidTestRation";
cout << "2. FutureValuen";
cout << "3. RateOfInterestn";
cout << "4. Company Xn";
cout << "5. Quitn";
cout << "Enter your choice (1-5): ";
cin >> choice;
while (choice < AcidTestRatio || choice> Quit)
{
cout << "Please enter valid choices (1-5)";
cin >> choice;
}
if (choice == AcidTestRatio)
{
FinancialCalculator one;
cout << "What is the Current Assets?";
cin >> CA;
cout << "Please enter the Inventory: ";
cin >> Inv;
cout << "What is the Current Liabilities?";
cin >> CL;
ATR = one.acidTestRatio(CA, Inv, CL);
cout << "Your Acid Test Ratio is" << ATR << endl;
}
else if (choice == FutureValue)
{
FinancialCalculator two;
cout << "What is the accounts present value?";
cin >> PV;
cout << "Please enter the interest rate in decimals: ";
cin >> r;
cout << "What is the number periods?";
cin >> n;
FV = two.futureValue(PV, r, n);
cout << "Your future value is: $" << FV << endl;
}
else if (choice == RateOfInterest)
{
FinancialCalculator three;
cout << "What is the total revenue?";
cin >> tr;
cout << "What is the total expenses?";
cin >> texp;
cout << "What is the cost of Investment?";
cin >> CoI;
roi = three.RateofInterest(tr, texp, CoI);
cout << "Your return on Investment is:" << roi << endl;
}
else if (choice == CompanyX)
{
FinancialCalculator four;
const int ARRAY_SIZE = 365;
double expenses[ARRAY_SIZE];
double revenue[ARRAY_SIZE];
int count = 0;
double lowest;
double highest;
double totalexp = 0;
double totalrev = 0;
double netprofit;
int expdate;
int revdate;
double roi;
ifstream inputFile;
ifstream inputFiletwo;
inputFile.open("C:UserskabitaDesktophw-2expenses.txt");
inputFiletwo.open("C:UserskabitaDesktophw-2revenue.txt");
// Read the numbers from the file into the array.
while (count < ARRAY_SIZE && inputFile >> expenses[count])
count++;
count = 0;
while (count < ARRAY_SIZE && inputFiletwo >> revenue[count])
count++;
// Close the file.
inputFile.close();
inputFiletwo.close();
//highest and lowest
highest = four.max(expenses, ARRAY_SIZE);
lowest = four.min(revenue, ARRAY_SIZE);
//other functions
cout << "For Company Xn";
cout << "-----------------------n";
cout << setprecision(2) << fixed << showpoint;
for (count = 0; count < ARRAY_SIZE; count++)
{
totalrev += revenue[count];
}
cout << "nRevenue Total:" << setw(14) << "$" << totalrev;
cout << setprecision(2) << fixed << showpoint;
for (count = 0; count < ARRAY_SIZE; count++)
{
totalexp += expenses[count];
}
cout << "nExpense Total:" << setw(14) << "$" << totalexp;
cout << "n n";
//linear search
cout << setprecision(2) << fixed << showpoint;
expdate = four.searchList(expenses, ARRAY_SIZE, highest);
string s = four.getDate(expdate);
cout << "Highest Expense:" << setw(14) << "$" << highest << "[" << s
<< "]" << endl;
cout << setprecision(2) << fixed << showpoint;
revdate = four.searchList(revenue, ARRAY_SIZE, lowest);
string s1 = four.getDate(revdate);
cout << "nSmallest Revenue:" << setw(14) << "$" << lowest << "[" << s1 << "]" << endl;
//other functions
cout << "n-----------------------n";
netprofit = totalrev - totalexp;
cout << setprecision(2) << fixed << showpoint;
cout << "nNet Total:" << setw(16) << "$" << netprofit;
roi = netprofit / totalexp * 100;
cout << setprecision(2) << fixed << showpoint;
cout << "nReturn on Investment:" << setw(5) << roi << "%";
cout << "What is the accounts present value?";
cin >> PV;
cout << "Please enter the interest rate in decimals: ";
cin >> r;
cout << "What is the number periods?";
cin >> n;
cout << "What is the total number of times compounded?";
cin >> t;
FVc a(PV, r, n, t);
cout << "Your future value compounded is: $" << a.getFVC() << endl;
}
} while (choice != Quit);
system("pause");
return 0;
}

More Related Content

What's hot

c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservationSwarup Kumar Boro
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
Lakshmi Sarvani Videla
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
Zohaib Ahmed
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)
Nitish Yadav
 
Mutation testing: Too good to be true? (4Developers)
Mutation testing: Too good to be true? (4Developers)Mutation testing: Too good to be true? (4Developers)
Mutation testing: Too good to be true? (4Developers)
Piotr Kubowicz
 
Cpds lab
Cpds labCpds lab
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
Computer Science investigatory project class 12
Computer Science investigatory project class 12Computer Science investigatory project class 12
Computer Science investigatory project class 12
Raunak Yadav
 
Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
Syed Tanveer
 
Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
Make Mannan
 
c++ program for Canteen management
c++ program for Canteen managementc++ program for Canteen management
c++ program for Canteen management
Swarup Kumar Boro
 
Programs for Operating System
Programs for Operating SystemPrograms for Operating System
Programs for Operating SystemLPU
 
C basics
C basicsC basics
C basicsMSc CST
 
C programms
C programmsC programms
C programms
Mukund Gandrakota
 
C programming
C programmingC programming
C programming
Muhammad Hamza
 
WordPressでIoTをはじめよう
WordPressでIoTをはじめようWordPressでIoTをはじめよう
WordPressでIoTをはじめよう
Yuriko IKEDA
 
Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
Murali Kummitha
 

What's hot (20)

c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)
 
Mutation testing: Too good to be true? (4Developers)
Mutation testing: Too good to be true? (4Developers)Mutation testing: Too good to be true? (4Developers)
Mutation testing: Too good to be true? (4Developers)
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Computer Science investigatory project class 12
Computer Science investigatory project class 12Computer Science investigatory project class 12
Computer Science investigatory project class 12
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
 
Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
 
C++ programs
C++ programsC++ programs
C++ programs
 
c++ program for Canteen management
c++ program for Canteen managementc++ program for Canteen management
c++ program for Canteen management
 
Programs for Operating System
Programs for Operating SystemPrograms for Operating System
Programs for Operating System
 
C basics
C basicsC basics
C basics
 
C programms
C programmsC programms
C programms
 
C programming
C programmingC programming
C programming
 
WordPressでIoTをはじめよう
WordPressでIoTをはじめようWordPressでIoTをはじめよう
WordPressでIoTをはじめよう
 
Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
 

Viewers also liked

Dissertation_Capital Structure final
Dissertation_Capital Structure finalDissertation_Capital Structure final
Dissertation_Capital Structure finalJasmin Taylor
 
PRESENTACIÓN HELADOS RICA CREMA
PRESENTACIÓN HELADOS RICA CREMAPRESENTACIÓN HELADOS RICA CREMA
PRESENTACIÓN HELADOS RICA CREMA
Helados Rica Crema Bucaramanga
 
Film magazine analysis
Film magazine analysisFilm magazine analysis
Film magazine analysis
oshin34
 
Formato sílabo 5
Formato sílabo 5Formato sílabo 5
Formato sílabo 5
Jean Pierre Buller
 
Relatório Actividades UMIC.PDF
Relatório Actividades UMIC.PDFRelatório Actividades UMIC.PDF
Relatório Actividades UMIC.PDFVanda de Jesus
 
Scalable and Efficient Algorithms for Analysis of Massive, Streaming Graphs
Scalable and Efficient Algorithms for Analysis of Massive, Streaming GraphsScalable and Efficient Algorithms for Analysis of Massive, Streaming Graphs
Scalable and Efficient Algorithms for Analysis of Massive, Streaming Graphs
Jason Riedy
 
Question 6
Question 6 Question 6
Question 6
ellasaund6
 
Maltrato infantil
Maltrato infantilMaltrato infantil
Maltrato infantil
Anyi Milena Ordoñez
 
1° básico b semana 18 al 22 de abril
1° básico b  semana 18 al 22  de abril1° básico b  semana 18 al 22  de abril
1° básico b semana 18 al 22 de abril
Colegio Camilo Henríquez
 
Foam stabilizer
Foam stabilizerFoam stabilizer
Foam stabilizer
Vohinh Ngo
 
Los principios aplicables a los titulos valores
Los principios aplicables a los titulos valoresLos principios aplicables a los titulos valores
Los principios aplicables a los titulos valores
Alfred Hinostroza Julca
 
Juegos calentamiento
Juegos calentamientoJuegos calentamiento
Juegos calentamiento
María Gordillo Aguilar
 
Reforma e concessão maracanã
Reforma e concessão maracanãReforma e concessão maracanã
Reforma e concessão maracanã
João Paulo Furtado
 
307154740-The-Clause-Issue-13 (1)
307154740-The-Clause-Issue-13 (1)307154740-The-Clause-Issue-13 (1)
307154740-The-Clause-Issue-13 (1)Amanda Mayfield
 
Contents page analysis
Contents page analysisContents page analysis
Contents page analysis
Apisan Selvarajah
 
A construção do_texto_coesão_e_coerência_textuais
A construção do_texto_coesão_e_coerência_textuaisA construção do_texto_coesão_e_coerência_textuais
A construção do_texto_coesão_e_coerência_textuais
Breno Lacerda
 
Javier a ayala c actividad1 2_mapac
Javier a ayala c actividad1 2_mapacJavier a ayala c actividad1 2_mapac
Javier a ayala c actividad1 2_mapac
Javier Ayala
 
Model model belajar dan rumpun model mengajar by dewinta susanti
Model model belajar dan rumpun model mengajar by dewinta susantiModel model belajar dan rumpun model mengajar by dewinta susanti
Model model belajar dan rumpun model mengajar by dewinta susanti
School
 

Viewers also liked (19)

Dissertation_Capital Structure final
Dissertation_Capital Structure finalDissertation_Capital Structure final
Dissertation_Capital Structure final
 
PRESENTACIÓN HELADOS RICA CREMA
PRESENTACIÓN HELADOS RICA CREMAPRESENTACIÓN HELADOS RICA CREMA
PRESENTACIÓN HELADOS RICA CREMA
 
Film magazine analysis
Film magazine analysisFilm magazine analysis
Film magazine analysis
 
Formato sílabo 5
Formato sílabo 5Formato sílabo 5
Formato sílabo 5
 
Relatório Actividades UMIC.PDF
Relatório Actividades UMIC.PDFRelatório Actividades UMIC.PDF
Relatório Actividades UMIC.PDF
 
Scalable and Efficient Algorithms for Analysis of Massive, Streaming Graphs
Scalable and Efficient Algorithms for Analysis of Massive, Streaming GraphsScalable and Efficient Algorithms for Analysis of Massive, Streaming Graphs
Scalable and Efficient Algorithms for Analysis of Massive, Streaming Graphs
 
Question 6
Question 6 Question 6
Question 6
 
Maltrato infantil
Maltrato infantilMaltrato infantil
Maltrato infantil
 
1° básico b semana 18 al 22 de abril
1° básico b  semana 18 al 22  de abril1° básico b  semana 18 al 22  de abril
1° básico b semana 18 al 22 de abril
 
Foam stabilizer
Foam stabilizerFoam stabilizer
Foam stabilizer
 
Los principios aplicables a los titulos valores
Los principios aplicables a los titulos valoresLos principios aplicables a los titulos valores
Los principios aplicables a los titulos valores
 
Juegos calentamiento
Juegos calentamientoJuegos calentamiento
Juegos calentamiento
 
Reforma e concessão maracanã
Reforma e concessão maracanãReforma e concessão maracanã
Reforma e concessão maracanã
 
307154740-The-Clause-Issue-13 (1)
307154740-The-Clause-Issue-13 (1)307154740-The-Clause-Issue-13 (1)
307154740-The-Clause-Issue-13 (1)
 
Contents page analysis
Contents page analysisContents page analysis
Contents page analysis
 
China The Next 30 Years
China  The Next 30 YearsChina  The Next 30 Years
China The Next 30 Years
 
A construção do_texto_coesão_e_coerência_textuais
A construção do_texto_coesão_e_coerência_textuaisA construção do_texto_coesão_e_coerência_textuais
A construção do_texto_coesão_e_coerência_textuais
 
Javier a ayala c actividad1 2_mapac
Javier a ayala c actividad1 2_mapacJavier a ayala c actividad1 2_mapac
Javier a ayala c actividad1 2_mapac
 
Model model belajar dan rumpun model mengajar by dewinta susanti
Model model belajar dan rumpun model mengajar by dewinta susantiModel model belajar dan rumpun model mengajar by dewinta susanti
Model model belajar dan rumpun model mengajar by dewinta susanti
 

Similar to project

Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd marchRajeev Sharan
 
Utility bill project.doc
Utility bill project.docUtility bill project.doc
Utility bill project.docJeremy Forczyk
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
Kyung Yeol Kim
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxEJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
leovasquez17
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxEJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
leovasquez17
 
c++ Lecture 2
c++ Lecture 2c++ Lecture 2
c++ Lecture 2sajidpk92
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
arjuncollection
 
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Dan Robinson
 
Simple design/programming nuggets
Simple design/programming nuggetsSimple design/programming nuggets
Simple design/programming nuggetsVivek Singh
 
Statement
StatementStatement
Statement
Ahmad Kamal
 
lesson 2.pptx
lesson 2.pptxlesson 2.pptx
lesson 2.pptx
khaledahmed316
 
Java Se next Generetion
Java Se next GeneretionJava Se next Generetion
Java Se next Generetion
Otávio Santana
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
Ashwin Francis
 
C++ programming
C++ programmingC++ programming
C++ programming
Pranav Ghildiyal
 
Penjualan swalayan
Penjualan swalayanPenjualan swalayan
Penjualan swalayan
Setiyo Agus Widjaja
 
1 introduction to c program
1 introduction to c program1 introduction to c program
1 introduction to c program
NishmaNJ
 
i want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docxi want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docx
hendriciraida
 

Similar to project (20)

Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
Utility bill project.doc
Utility bill project.docUtility bill project.doc
Utility bill project.doc
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxEJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
 
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docxEJERCICIOS DE BORLAND C++ 2DA PARTE.docx
EJERCICIOS DE BORLAND C++ 2DA PARTE.docx
 
c++ Lecture 2
c++ Lecture 2c++ Lecture 2
c++ Lecture 2
 
Banking Database
Banking DatabaseBanking Database
Banking Database
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
 
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
 
Simple design/programming nuggets
Simple design/programming nuggetsSimple design/programming nuggets
Simple design/programming nuggets
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Statement
StatementStatement
Statement
 
lesson 2.pptx
lesson 2.pptxlesson 2.pptx
lesson 2.pptx
 
Java Se next Generetion
Java Se next GeneretionJava Se next Generetion
Java Se next Generetion
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Penjualan swalayan
Penjualan swalayanPenjualan swalayan
Penjualan swalayan
 
1 introduction to c program
1 introduction to c program1 introduction to c program
1 introduction to c program
 
i want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docxi want to add to this c++ code a condition so that you can only chose.docx
i want to add to this c++ code a condition so that you can only chose.docx
 

project

  • 1. #include <iostream> #include <cmath> #include<string> #include<fstream> #include<iomanip> using namespace std; class FinancialCalculator { private: double FV; double roi; double ATR; double presentvalue, rate; int period; public: FinancialCalculator(); FinancialCalculator(double PV, double r, int n); double acidTestRatio(double i, double j, double k); double futureValue(double x, double y, int z); double RateofInterest(double a, double b, double c); string getDate(int date); double min(double[], int); double max(double[], int); double getPV(); double getr(); int getn(); int searchList(const double[], int, double); }; FinancialCalculator::FinancialCalculator() { cout << "Please enter the following" << endl; } double FinancialCalculator::futureValue(double PV, double r, int n) { double FV; FV = PV * pow((1 + r), n); return FV; } double FinancialCalculator::RateofInterest(double tr, double texp, double CoI) { double roi; roi = ((tr - texp) - CoI) / CoI; return roi; } double FinancialCalculator::acidTestRatio(double CA, double Inv, double CL) { double ATR; ATR = (CA - Inv) / CL; return ATR; } int FinancialCalculator::searchList(const double revenue[], int ARRAY_SIZE, double lowest) { int index = 0; int position = -1; bool found = false;
  • 2. while (index < ARRAY_SIZE && !found) { if (revenue[index] == lowest) { found = true; position = index; } index++; } return position; } string FinancialCalculator::getDate(int date) { string dates; if (date < 31) { dates = "January " + to_string(date + 1) + " 2015"; } else if (date < 59) dates = "February " + to_string(date - 31 + 1) + " 2015"; else if (date < 90) dates = "March " + to_string(date - 59 + 1) + " 2015"; else if (date < 120) dates = "April " + to_string(date - 90 + 1) + " 2015"; else if (date < 151) dates = "May " + to_string(date - 120 + 1) + " 2015"; else if (date < 181) dates = "June " + to_string(date - 151 + 1) + " 2015"; else if (date < 212) dates = "July " + to_string(date - 181 + 1) + " 2015"; else if (date < 243) dates = "August " + to_string(date - 212 + 1) + " 2015"; else if (date < 273) dates = "September " + to_string(date - 243 + 1) + " 2015"; else if (date < 304) dates = "October " + to_string(date - 273 + 1) + " 2015"; else if (date < 334) dates = "November " + to_string(date - 304 + 1) + " 2015"; else dates = "December " + to_string(date - 334 + 1) + " 2015"; return dates; } double FinancialCalculator::min(double revenue[], int ARRAY_SIZE) { int count; double lowest; lowest = revenue[0]; for (count = 1; count < ARRAY_SIZE; count++) { if (revenue[count] < lowest) lowest = revenue[count]; } return lowest; } double FinancialCalculator::max(double expenses[], int ARRAY_SIZE) { int count; double highest; highest = expenses[0];
  • 3. for (count = 1; count < ARRAY_SIZE; count++) { if (expenses[count] > highest) highest = expenses[count]; } return highest; } FinancialCalculator::FinancialCalculator(double PV, double r, int n) { presentvalue = PV; rate = r; period = n; } double FinancialCalculator::getPV() { return presentvalue; } double FinancialCalculator::getr() { return rate; } int FinancialCalculator::getn() { return period; } class FVc : public FinancialCalculator { private: int times; double FVC; public: FVc(double PV, double r, int n, int t) : FinancialCalculator(PV, r, n) { times = t; setFVC(PV, r, n, t); } void setFVC(double PV, double r, int n, int t) { FVC = PV * pow((1 + (r / t)), (n*t)); } double getFVC() { return FVC; } }; int main() { const int AcidTestRatio = 1, FutureValue = 2, RateOfInterest = 3, CompanyX = 4, Quit = 5; int choice; double CA, Inv, CL, ATR; int t, n; double PV, r, FV; double CoI, tr, texp, roi; do
  • 4. { cout << "MENU OPTIONS:n"; cout << "1. AcidTestRation"; cout << "2. FutureValuen"; cout << "3. RateOfInterestn"; cout << "4. Company Xn"; cout << "5. Quitn"; cout << "Enter your choice (1-5): "; cin >> choice; while (choice < AcidTestRatio || choice> Quit) { cout << "Please enter valid choices (1-5)"; cin >> choice; } if (choice == AcidTestRatio) { FinancialCalculator one; cout << "What is the Current Assets?"; cin >> CA; cout << "Please enter the Inventory: "; cin >> Inv; cout << "What is the Current Liabilities?"; cin >> CL; ATR = one.acidTestRatio(CA, Inv, CL); cout << "Your Acid Test Ratio is" << ATR << endl; } else if (choice == FutureValue) { FinancialCalculator two; cout << "What is the accounts present value?"; cin >> PV; cout << "Please enter the interest rate in decimals: "; cin >> r; cout << "What is the number periods?"; cin >> n; FV = two.futureValue(PV, r, n); cout << "Your future value is: $" << FV << endl; } else if (choice == RateOfInterest) { FinancialCalculator three; cout << "What is the total revenue?"; cin >> tr; cout << "What is the total expenses?"; cin >> texp; cout << "What is the cost of Investment?"; cin >> CoI; roi = three.RateofInterest(tr, texp, CoI); cout << "Your return on Investment is:" << roi << endl; } else if (choice == CompanyX) { FinancialCalculator four; const int ARRAY_SIZE = 365; double expenses[ARRAY_SIZE]; double revenue[ARRAY_SIZE]; int count = 0; double lowest;
  • 5. double highest; double totalexp = 0; double totalrev = 0; double netprofit; int expdate; int revdate; double roi; ifstream inputFile; ifstream inputFiletwo; inputFile.open("C:UserskabitaDesktophw-2expenses.txt"); inputFiletwo.open("C:UserskabitaDesktophw-2revenue.txt"); // Read the numbers from the file into the array. while (count < ARRAY_SIZE && inputFile >> expenses[count]) count++; count = 0; while (count < ARRAY_SIZE && inputFiletwo >> revenue[count]) count++; // Close the file. inputFile.close(); inputFiletwo.close(); //highest and lowest highest = four.max(expenses, ARRAY_SIZE); lowest = four.min(revenue, ARRAY_SIZE); //other functions cout << "For Company Xn"; cout << "-----------------------n"; cout << setprecision(2) << fixed << showpoint; for (count = 0; count < ARRAY_SIZE; count++) { totalrev += revenue[count]; } cout << "nRevenue Total:" << setw(14) << "$" << totalrev; cout << setprecision(2) << fixed << showpoint; for (count = 0; count < ARRAY_SIZE; count++) { totalexp += expenses[count]; } cout << "nExpense Total:" << setw(14) << "$" << totalexp; cout << "n n"; //linear search cout << setprecision(2) << fixed << showpoint; expdate = four.searchList(expenses, ARRAY_SIZE, highest); string s = four.getDate(expdate); cout << "Highest Expense:" << setw(14) << "$" << highest << "[" << s << "]" << endl; cout << setprecision(2) << fixed << showpoint; revdate = four.searchList(revenue, ARRAY_SIZE, lowest); string s1 = four.getDate(revdate);
  • 6. cout << "nSmallest Revenue:" << setw(14) << "$" << lowest << "[" << s1 << "]" << endl; //other functions cout << "n-----------------------n"; netprofit = totalrev - totalexp; cout << setprecision(2) << fixed << showpoint; cout << "nNet Total:" << setw(16) << "$" << netprofit; roi = netprofit / totalexp * 100; cout << setprecision(2) << fixed << showpoint; cout << "nReturn on Investment:" << setw(5) << roi << "%"; cout << "What is the accounts present value?"; cin >> PV; cout << "Please enter the interest rate in decimals: "; cin >> r; cout << "What is the number periods?"; cin >> n; cout << "What is the total number of times compounded?"; cin >> t; FVc a(PV, r, n, t); cout << "Your future value compounded is: $" << a.getFVC() << endl; } } while (choice != Quit); system("pause"); return 0; }