Hey guys, first post so first I'd like to say hello. I've followed the site and read multiple tutorials for C++ so far. I'm actually going to school for programming. Although I'm quite the beginner, I'm very eager to learn.
I have this issue with some very basic code that I figured maybe someone could point me in the right direction to a solution. Basically if I leave the calculations out, I can get the outputs displayed, but once I add them in, only the input works. Anyways, onto the code.
Thanks for any help in advance!Code:#include <iostream> #include <string> using namespace std; //declaring global variables double totalPrice = 0; double purchasePrice = 0; double totalTax = 0; float countyTax = 0; float stateTax = 0; //prototpyes void input(); void calc(); void output(); int main() { //calls in main input(); calc(); output(); system("pause"); return 0; } void input() { cout << "Enter your purchase price: "; cin >> purchasePrice; }//end of input void calc() { countyTax = purchasePrice * .02; cin >> countyTax; stateTax = purchasePrice * .04; cin >> stateTax; totalTax = stateTax + countyTax; cin >> totalTax; totalPrice = (stateTax + countyTax) * purchasePrice; cin >> totalPrice; } //end of calc void output() { cout << "Your purchase cost: " << purchasePrice << endl; cout << "Your total county sales tax is: " <<countyTax << endl; cout << "Your total state sales tax is : " <<stateTax <<endl; cout << "Your total purchase cost including tax is: " <<totalPrice <<endl; } //end of output



LinkBack URL
About LinkBacks



