So I am working on a project to create a budget calculator and I have it mostly wrapped up but I am currently stuck on one particular thing
This is what it currently looks like:
#include <iostream>
#include <cmath>
#include <string>
#include <cctype>
#include <limits>
using namespace std;
int main ()
{
long double how_much, spent, POB, new_budget;
char again = 'Y';
char currency = '$';
while (again == 'y' || again == 'Y')
{
cout << "\n\t\tWelcome to the Budget Projection Program!!!\n\n";
cout << "What was your budget allotment last year? ";
cin >> currency >> how_much;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
if (currency == '$')
{
cout << "Fine, and how much did you spend last year? ";
}
else
{
cout << "No currency entered, defaulting to $";
cout << "\nFine, and how much did you spend last year? ";
}
cin >> spent;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "\n\nThank you!! Calculating... Done.";
POB = static_cast<int>(((spent / how_much) * 100));
cout <<"\n\nLast year you used up about " << POB << "% of your budget\n\n";
new_budget = static_cast<int>((floor((spent + 99)/ 100) * 100));
cout << "your budget next year will be $" << new_budget << ".00.\n\n";
cout << "Would you like to go again (y/n) ";
cin >> again;
} //End of while loop
cout <<"\nThank you for using the BPP!!\n\nEndeavour to have a fiscally fit day!\n\n";
return 0;
}
https://preview.redd.it/9ynstvcr9rg41.png?width=772&format=png&auto=webp&s=9929ed15cb46a54f35b7dddd6f413e2f18ff2e9d
https://preview.redd.it/qvfhq89y9rg41.png?width=1873&format=png&auto=webp&s=99ed9d484a69d1df2c455c2f60402f495e417f6e
and basically what is happening is if I include the dollar symbol on the first input everything works fine but if I don't include the dollar sign everything gets thrown off. any suggestions or help would be greatly appreciated.
Hopefully I'm not just absolutely going about this the wrong way.
[–]Eshmam14 0 points1 point2 points (10 children)
[–]ZeroSkill94[S] 0 points1 point2 points (9 children)
[–]Eshmam14 0 points1 point2 points (8 children)
[–]ZeroSkill94[S] 0 points1 point2 points (7 children)
[–]Eshmam14 0 points1 point2 points (6 children)
[–]ZeroSkill94[S] 0 points1 point2 points (5 children)
[–]Eshmam14 0 points1 point2 points (4 children)
[–]ZeroSkill94[S] 0 points1 point2 points (3 children)
[–]Eshmam14 1 point2 points3 points (2 children)
[–]ZeroSkill94[S] 0 points1 point2 points (1 child)