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.
yvonnesooAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
niemeyerConnect With a Mentor Commented:
This is the correct code:

#include <iostream>
main ()
{
  float price,commission;
  cout << "Enter sale price: " << endl;
  cin >> price;
  commission = 0.075*price;
  cout << endl << "Your commission is " << commission << endl;
}
0
 
KangaRooCommented:
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.
0
 
yvonnesooAuthor Commented:
what do you mean? i don't understand.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ozoCommented:
"10234084.cpp", line 7: error(3158): expected a ";"
   commission=0.075 * price  cout <<"\n Your commission is"<<commission;
                             ^
0
 
KangaRooCommented:
You have to add the semicolon at the end of the statement. change
  commission=0.075 * price
to
  commission=0.075 * price;
0
 
allymCommented:
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
0
 
KangaRooCommented:
Niemeyer, you're taking other peoples comments as answer.
0
All Courses

From novice to tech pro — start learning today.