cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Beginners : Will not build without errors
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programm...
Articles
Lounge
Jobs

-

post  Will not build without errors

Ray (20)
Can anyone help me to find out why this program does not build without errors?

///*specification: Raymond Henry Sr Lab2 exercise 1
//"Pen Pricing"

#include "stdafx.h";
#include <iomanip>;
using namespace std;
using std::cout;
using std::cin;
using std::endl;


int pensOrdered = 0;
double penPrice = 0.00;
double totalPrice = 0.00;
const double pensTo50 = .50;
const double pensTo100 = .48;
const double pensTo500 = .45;
const double pensOver500 = .42;

int main ()
{
//Menu
cout<< "Pen Order. "<<endl;
cout<< "Our Pen Prices:"<<endl;
cout<< "0-50 pens ... 50 cents each" <<endl;
cout<< "51-100 pens ... 48 cemts each" <<endl;
cout<< "101-499 pens ... 45 cents each" <<endl;
cout<< "500+ pens ... 42 cents each" <<endl;
cout<< "How many pens would you like to order?";
cin>> pensOrdered;

//Calculations
if(pensOrdered < 51)
{
totalPrice = pensOrdered * pensTo50;
penPrice = pensTo50;
}
else
{
if(pensOrdered < 101)
{
totalPrice = pensOrdered * pensTo100;
penPrice = pensTo100;
}
else
{
if(pensOrdered < 500)
{
totalPrice = pensOrdered * pensTo500;
penPrice = pensTo500;
}
else
{
totalPrice = pensOrdered * pensOver500;
penPrice = pensOver500;
};
};
};

//Overall Output
cout<<endl<< pensOrdered;
cout<< " pens were ordered at a price of $ ";
cout<< penPrice;
cout<< " each for a total of $ ";
cout<< totalPrice;
cout<< "." <<endl;
return 0;
}
|
Lodger (4)
Remove the semicolons from the end of your #include statements.

1
2
#include "stdafx.h" ;  // Remove the ';'s 
#include <iomanip> ; 


Should be...

1
2
#include "stdafx.h"
#include <iomanip> 
|
simply thunder (30)
also don't need them after if blocks
it would probably still compile with out errors, but you don't need them
it an empty line

correct me if (i'm wrong) {}; :D
|
Ray (20)
I figured it out. But simply thunder thank you so much you led me to the resolution. I also forgot to include #include <iostream> and once that was added it built without errors and worked.
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2009 - All rights reserved - v2.2
Spotted an error? contact us