Offistart - Virtual Offices, Office Space, Business Support Services
*Home>>>Commercial Space

C++ program need help?


/***************************************...
* fuwen xu 05/11/07 switch and looping.cpp *
* This program compute the commissions for the real estate company *
* Input:choice,agent_id,rsp,csp,msp,yesno,... *
* Output:nr,nc, nm,mc,trc,tcc, *
************************************** HISTORY ****************************
* Who Date Description *
**************************************...
* Fuwen Xu 05/11/2007 calculate commissions *
**************************************...
#include <iostream>
#include <iomanip>
using namespace std;

#define RCR 0.1 /*residential commission rate*/
#define CCR 0.2 /*commercial commission rate*/
#define MCR 0.15 /*multiunt dwelling commission rate*/

int main()
{
int id, /*five digit number ID*/
price, /*selling pricce*/
nr=0, /*number of residential commissions computed*/
nc=0, /*number of commerical commissions computed*/
nm=0, /*number of multiunit commissions computed*/
yesno; /* program loops when = 1*/
double trc=0.0 , /*total of residential commissions*/
tcc=0.0 , /*total of commerical commissions*/
tmc=0.0 ; /*total of multiunit dwelling commissions*/
char choice, /*choose the what category r, c, m*/
space = ' '; /*space*/

cout << "\n\n\n\n";
cout << "\n***************Fuwen Commission Computer******************\n";
cout << "\nDo you have a commission to compute?(1 = yes, 0 = no)? ";
cin >> yesno;
while (yesno == 1)
{
cout << "\nPlease enter the Agent ID: ";
cin >> id;
cout << "\nPlease enter the category of property sold";
cout << "\n(R = residential, C = commercial, M = multiunit): ";
cin >> choice;
switch(choice)
{
case 'r':
case 'R':
trc-=trc;
cout <<"Please enter the selling price: ";
cin >> price;
trc += (price*RCR);
nr += 1;
cout <<"\n\nThe commission for this sale for Agent "<<space<<id;
cout <<" is: "<<setw(2)<<fixed<<setprecision(2)<<trc;
break;
case 'c':
case 'C':
tcc-=tcc;
cout <<"Please enter the selling price: ";
cin >> price;
tcc += (price*CCR);
nc+=1;
cout <<"\n\nThe commission for this sale for Agent "<<space<<id;
cout <<" is: "<<setw(2)<<fixed<<setprecision(2)<<tcc;
break;
case 'M':
case 'm':
tmc-=tmc;
cout <<"Please enter the selling price: ";
cin >> price;
tmc += (price*MCR);
nm+=1;
cout <<"\n\nThe commission for this sale for Agent "<<space<<id;
cout <<" is: "<<setw(2)<<fixed<<setprecision(2)<<tmc;
break;
default:
cout << "\nAn invalid value was entered.\n";
}
cout << "\n\n";
cout << "\nDo you have another commission to compute?(1 = yes,0 = no)? ";
cin >> yesno;
}
trc+=trc;
tcc+=tcc;
tmc+=tmc;
cout << "\n\n********************End of Run Report************************";
cout << "\n\nTotal number of Residential commissions computed = "<<nr;
cout << "\nTotal number of Commercial commissions computed = "<<nc;
cout << "\nTotal number of Multiunit commissions computed = "<<nm;
cout << "\nTotal number of all commissions computed = "<<(nr+nc+nm);
cout << "\n\nTotal amount of Redidential commissions computed = "<<setw(9)<<fixed<<setprecision(2)<<tr...
cout << "\nTotal amount of Commercial commissions computed = " <<setw(9)<<fixed<<setprecision(2)<<tcc;
cout << "\nTotal amount of Multiunit commissions computed = "<<setw(9)<<fixed<<setprecision(2)<<tm...
cout << "\n\nTotal amount of all commissions computed = "<<" $ "<<setw(12)<<fixed<<setprecision(2)<<(tr...
cout << "\n";
return 0;


}

I can't get the total of each sale that user enter their data over twice. first I need the program to show each single result user enter. after all i want to get the total valume of all each single result....



for example. i run that program.
enter: 1 , id#(the #whatever you want) , r , 50, (then program show sales is 5.00)

then keep on enter : 1, id#(the #whatever you want) , r , 100(then program show sales is 10.0)

finally i enter : 0(to end the program)

than i want the result is total residantial sale is "15 "


i can't get the final result like that .someone help me up. it bother me whole weekkkkkkkkkkkk

Your code doesn't keep an accurate total count of sales. For example, for switch case r/R you have trc-=trc, basically setting trc = 0 EVERY TIME switch case r/R is run. So the count is essentially wiped out all the time and when you're done the count isn't correct.

Err, whats your question?

Well, what's the problem?

(You're better off telling us the problem is than just posting the code. When we see the code, Y!Answers will truncate long lines so we can't just cut and paste it into our compilers.)

BigRez,
who says u to "cut" and "paste".
if u know the answer then
just "select" and"copy" then "paste" to C++.

Sorry i can't anser to question b/c i am C student not C++.

Tags
  Rent Offices   Business Centers   Service Offices   Branch Offices   Temporary Offices   Shared Offices   Commercial Space   Office Space   Business Services   Business Address   Call Forwarding   Call Handling
Related information
  • Air Travels Affect on the Whether & The Atmospher?

    The size of our planet and the magnetic field the molten core creates keeps the atmosphere around us. Air travel does cause global "dimming" though. Water particals are tiny spheres that ...

  • (linear programming) Aid to Disaster Victiins An agency wants to ship food and clothing to hurricane?

    Let x1 be the number of cartons of food sent Let x2 be the number of cartons of clothing sent. Then your objective function is: Z = 10x1 + 8x2 With constraints 20x1 + 30x2 <= 18000 40x1 ...

  • Plz read. I know it seems kinda long. It's worth it. Really Really funny!!!!?

    Sometimes when getting a new PC, I can almost see these statement on them. Excellent read! Thoroughly enjoyed it. For those that came in here just for the 2 points and wrote a worthless repons...

  • Didn鈥檛 the Rich Help Make America Great, Too?.?

    Many rich people supported the revolution for economic reasons. One of my ancestors was very active in financing the revolution, and you will find his signature on a lot of continental currency. He...

  • Famous company's commercials?

    Because it keeps the product in the consumers mind. Studies show aggressive commercial campaigns boost profits by at least 25% a quarter. They are large and in charge if you see a commercial about...

  • Ok - My 1st Computer (PC) "Build" ...?

    go with the pentium 2 prosser and i must say you do know your stuff and keep up larning about you computer. ya got skills I can tell by reading what you wrote. Webmaster, Jonathan Bucci bucciki...

  • What is the biggest mistake USA did and India followed the same just blind folded?

    Many many factors contribute why certain cities and locations keep growing without bounds while others do not. Examples are like available natural resources, manpower, energy, climate, traffic, cri...

  • Would you also like to see the entire cast of High School Musical?

    i hate them no offenses

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster