GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 17-Jul-2012, 16:02
BlindFury007 BlindFury007 is offline
New Member
 
Join Date: Jul 2012
Posts: 2
BlindFury007 is on a distinguished road

TaxAmount rate is always wrong


Hello everyone first time posting so feel free to let me know if I am posting wrong in anyway.
I was have to create a program with the following information. (Attache in pdf file)
I almost got it to work, however when it come down to the TaxAmount the rate is always wrong.
For example if the commission is $2000.00 It will multiply by .06 instead of .09.
Thanks in advance

//EZ-TECH//
CPP / C++ / C Code:
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
 //Declaring Variables//  
char letter; //Yes//
int Sales; //Sales//
int Numberofsales1 = 0; //Number Of Sales East Coast//
int Numberofsales2 = 0; //Number Of Sales West Coast//
int Code; //Region Code//
double Totalsales1; //East Coast Total Sales//
double Totalsales2; //West Coast Total Sale//
double Average; //Average Sale for Both Regions//
double Commission; //Commission Amount/Gross//
double Total; // Combine Regions//
double TaxAmount; //Tax Amount//
double NetPay; //Net Pay//
double TaxRate; //Gross Tax Rate//
double CommissionRate; //Commission Rate
double CommissionAmount; // Commission Amount//


while (letter != 'Y')
{
cout<< "Enter 1 for East Coast or 2 for West Coast: ";
cin>> Code;

cout<< "Enter total sales for the region: ";
cin>> Sales;                                                                                 
switch (Code)
{
case 1:
Totalsales1 += Sales;
Numberofsales1++;
break;
case 2:
Totalsales2 += Sales;
Numberofsales2++;
break;
}//Close Switch//

cout << "Do you want to stop the program? ";
cin >> letter;  
                   


//Two Decimal Points//
cout<<setprecision(2); 



}//Close While//
{
if (Commission > 6000) TaxRate = .18;
else if ((Commission >= 3000) && (Commission <= 5999)) TaxRate = .15;
else if ((Commission >= 1500) && (Commission <= 2999)) TaxRate = .09;
else if (Commission < 1499) TaxRate = .06;
TaxAmount = Commission * TaxRate;
}

//Calculation//If statements//
Total =  Totalsales1+Totalsales2;
Average = Total/2;
Commission = Total*.18;
TaxAmount = Commission*TaxRate;
NetPay = Commission-TaxAmount;   


//Output//
cout<< "Name Of Salesperson: "            << "Whatever" << endl; 
cout<< "Total Sales For East Coast:     $" << fixed << Totalsales1  << endl;
cout<< "Total Sales For West Coast:     $" << fixed << Totalsales2  << endl;
cout<< "Number Of Sales For East Coast:  " << Numberofsales1 << endl; 
cout<< "Number Of Sales For West Coast:  " << Numberofsales2 << endl;
cout<< "Average Sales For Both Regions: $" << Average << endl; 
cout<< "Commisson Amount:                $" << Commission << endl;              
cout<< "Tax Amount:                               $" << TaxAmount << endl;                     
cout<< "Net Pay:                                     $" << NetPay << endl;

//End of Program//
system("Pause");
return 0;
}
Last edited by LuciWiz : 18-Jul-2012 at 02:51. Reason: Please insert your C++ code between [cpp] & [/cpp] tags
  #2  
Old 17-Jul-2012, 17:55
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,441
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Due Tomorrow! Can't seeem to get the if statements right


Hint: comparing 'Commission' before it is assigned any value?

I enabled warnings when compiling your code, and got this output:
Code:
$ g++ -Wall file.cpp gid.cpp: In function `int main()': gid.cpp:20:8: warning: unused variable `CommissionRate' gid.cpp:21:8: warning: unused variable `CommissionAmount' gid.cpp:55:1: warning: `Commission' is used uninitialized in this function
To see what the commission's value has, print its value before that first if, and you'll see.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
  #3  
Old 17-Jul-2012, 21:40
BlindFury007 BlindFury007 is offline
New Member
 
Join Date: Jul 2012
Posts: 2
BlindFury007 is on a distinguished road

Re: Due Tomorrow! Can't seeem to get the if statements right


Thank you very much, I thought I tried this but I guess I over looked it. Programs are tricky and I'm new to this, sorry for the noob thread.
Again thank you for the support and timely reply.
 
 

Recent GIDBlogGID Spam Detector 1.1.0 by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with tele directory problem due tomorrow wbsquared03 C++ Forum 5 01-Nov-2004 23:10
Change Default Project Statements in Dev-C++?? BobbyMurcerFan C++ Forum 1 22-Jun-2004 23:59
Pointers to Functions (was Saving some if statements) TekiFreek C++ Forum 17 17-Jun-2004 11:25

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:33.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.