You need to define the two functions that you want to use, just like you define the variable in your program
Code:
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
long double amount = 0; // these are global vars. it is safer to
long double earn = 0; // move these inside of the main fun.
long double percent = 0; // and pass b/n functions.
int weeks = 0;
int result = 0;
void verOne(); // Define your functions too
void verTwo(); // Define your functions too
int main()
{
int choice;
cout << "Would you like to run version 1 or version 2? ";
cin >> choice;
switch(choice)
{
case 1: verOne();
break;
case 2: verTwo();
break;
}
return 0;
}
void verOne()
{
// get info
system("cls");
cout << "Enter the amount of money that you would like to save:$";
cin >> amount;
cout << "\n";
cout << "Enter the amount of money that you earn each week:$";
cin >> earn;
cout << "\n";
cout << "Enter the percentage of your weekly earnings that you would\n";
cout << "like to save each week: ";
cin >> percent;
cout << "\n";
// calculate end result
percent = percent/earn * 100;
result = amount/percent;
if(result < 1)
{
cout << "It would take you 1 week to reach your target.\n";
exit(0);
}
else
{
cout << "It would take you ";
cout << result;
cout << " week(s) to reach your target.\n";
exit(0);
}
}
void verTwo()
{
//get info
system("cls");
cout << "Enter the amount of money that you would like to save:$";
cin >> amount;
cout << "\n";
cout << "Enter the maximum amount of weeks that you have to save this money: ";
cin >> weeks;
// calculate result
result = amount/weeks;
cout << "You would have to save $";
cout << result;
cout << " each week for ";
cout << weeks;
cout << " weeks.";
cout << "\n";
exit(0);
}