I am trying to figure out how to run programs and compile them in C++ if anyone can help please let me know. The major problem I am having is on this particular problem Prb04-3.cpp it will not let me run it. I tried to paste it on here and wont do it for some reason.

Thanks
Cutieshunky

Recommended Answers

All 6 Replies

Drag mouse to highlight the text, Ctrl+C, go to place you want it copied, Ctrl+V.

This is what I have and it will not run

// This program determines the commission on real estate sales
// depending on the type of property sold.

#include <iostream>
#include <iomanip>
#include <cstd1ib>

using namespace std;

int main ()
{
  const double       RESIDENTIAL_RATE + 0.060;
  const double       MULTIDWELLING_RATE = 0.050;
  cont double         COMMERCIAL_RATE = 0.045;

int          property_code;
double    sale_price,
             commission_rate,
             commission;

cout << setprecision (2)
       << setiosflags (ios::fixed)
       << setiosflags (ios::showpoint) ;
cout << "Enter the property's selling price: ";
cin >> sale price;

cout << end1 ;
cout << "Enter the property code according to the following."
       << end1 << end1 ;
cout << "Residental,            enter R" << end1;
cout << "Multiple Dwelling,   enter M" << end1;
cout Commercial,                enter C" << end1 << end1;
cout << "Please make your selection:  :;

cin. get () ;                 // Discard the \n
property_code = cin.get () ;

    if( property_code == 'R' || property_code == 'r')
    {
       commission_rate = RESIDENTAL_RATE;
    }
    else if( property_code == 'M' || property_code == 'm')
    {
        commission_rate = COMMERCIAL_RATE;

    }
    else
    {
         cout << end1 << end1
                <<"Invalid Property Code! Try Again" << end1;
         exit(1);
    }
////////////////////////////////////////////////////////////////////

    commission = sale_price * commission_rate;

    cout << end1 << end1;
    cout << "The commsiion is " << commission << end1;

    return 0;
}

One, site rule, use CODE TAGS.
Two, I'm sure it won't compiler with non-existent <cstd1ib>.
Three, don't use exit(). You're in main() so why not just return(1)?

That's just all I saw while scrolling down the page. Use the code tags, and then people may be more compliant to help you.

What do you mean by code tags

All of the problems with the code you posted are due to carelessness -- misspelled words. When programming you have to learn to pay attention to small details, such as capitalization and spelling. Look at your compilers error messages and fix the problems one at a time. Normally the first error message is the most important. Fix it then recompile to see what's left.

Here is the program with all those errors corrected. I didn't run the program so I don't know if it works correctly or not.

// This program determines the commission on real estate sales
// depending on the type of property sold.

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

int main ()
{
  const double       RESIDENTIAL_RATE = 0.060;
  const double       MULTIDWELLING_RATE = 0.050;
  const double         COMMERCIAL_RATE = 0.045;

int          property_code;
double    sale_price,
             commission_rate,
             commission;

cout << setprecision (2)
       << setiosflags (ios::fixed)
       << setiosflags (ios::showpoint) ;
cout << "Enter the property's selling price: ";
cin >> sale_price;

cout << endl ;
cout << "Enter the property code according to the following."
       << endl << endl ;
cout << "Residental,            enter R" << endl;
cout << "Multiple Dwelling,   enter M" << endl;
cout << "Commercial,                enter C" << endl << endl;
cout << "Please make your selection:  :";

cin. get () ;                 // Discard the \n
property_code = cin.get () ;

    if( property_code == 'R' || property_code == 'r')
    {
       commission_rate = RESIDENTIAL_RATE;
    }
    else if( property_code == 'M' || property_code == 'm')
    {
        commission_rate = COMMERCIAL_RATE;

    }
    else
    {
         cout << endl << endl
                <<"Invalid Property Code! Try Again" << endl;
         exit(1);
    }
////////////////////////////////////////////////////////////////////

    commission = sale_price * commission_rate;

    cout << endl << endl;
    cout << "The commsiion is " << commission << endl;

    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.