Link to home
Start Free TrialLog in
Avatar of yvonnesoo
yvonnesoo

asked on

run problem

i try to run a program but it won't work out and there are error. may i know what the problem i have done? this is my program.
===============================
#include <iostream.h>
main ()
{
 float price,commission;
 cout <<"Enter sale price"<<'\n';
 cin >>price;
 commission=0.075 * price
 cout <<"\n Your commission is"<<commission;
}
============================
FYI, this is my program question:-
A salesperson selling a piece of real estate, receives 7.5% commission. Enter the sales price and respond by displaying the commission and have a blank line between the input and output value.
Please correct me if i have done mistake.
Avatar of KangaRoo
KangaRoo

You forgot a ; behind the line that calculates the commission and the newline should probably be written after the price has been read and before the commission is written.
Avatar of yvonnesoo

ASKER

what do you mean? i don't understand.
Avatar of ozo
"10234084.cpp", line 7: error(3158): expected a ";"
   commission=0.075 * price  cout <<"\n Your commission is"<<commission;
                             ^
You have to add the semicolon at the end of the statement. change
  commission=0.075 * price
to
  commission=0.075 * price;
ASKER CERTIFIED SOLUTION
Avatar of niemeyer
niemeyer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
They are right, you need the ";" after "commission=0.075 * price".  

You will want to put an endl in apropriate places. This puts a CR/LF in and flushes the IO stream, otherwise your text might not appear on the monitor until the buffer fills up. It might not be a problem on this simple program, or with your current compiler and operating system, but you might get confused on bigger programs or if things change.  

Use "cout <<"\n Your commission is"<<commission << endl;"
and  

cout <<"Enter sale price"<< endl;

instead.  

ALSO, you COULD HAVE put the '\n' as part of the string instead of separately

 cout <<"Enter sale price\n";

Ally
Niemeyer, you're taking other peoples comments as answer.