Okay, I am writing this program for class and it kind of works. It goes through the motions, but would skip the prompt where I ask if they want to add another customer. So, I realized I missed a bracket on an if statement and it brought up this error after I corrected it:
c:\docume~1\stepha~1\desktop\progra~3.cpp:160: ANSI C++ forbids declaration `system' with no type
c:\docume~1\stepha~1\desktop\progra~3.cpp:160: `int system' redeclared as different kind of symbol
C:\DEV-C_~1\Include\stdlib.h:283: previous declaration of `int system(const char *)'
c:\docume~1\stepha~1\desktop\progra~3.cpp:160: initialization to `int' from `const char *' lacks a cast
c:\docume~1\stepha~1\desktop\progra~3.cpp:161: parse error before `return'
Here is the code: - #include <iostream.h>
-
#include <stdlib.h>
-
#include <fstream>
-
#include <string>
-
#include <iomanip>
-
#include <math.h>
-
using namespace std;
-
-
char cust_name[40];
-
double length;
-
double width;
-
double stories;
-
double pitch;
-
double total_cost;
-
double siding_cost;
-
double roofing_cost;
-
double area_siding;
-
double area_roofing;
-
double roof_width;
-
double roofing_squares;
-
double siding_squares;
-
double triangle_1;
-
double triangle_2;
-
double triangle_height;
-
double triangle_width;
-
double triangle_area;
-
double triangle;
-
double sides;
-
double total_roofing_cost;
-
double total_siding_cost;
-
int siding_type;
-
int roofing_type;
-
int next_customer;
-
const double height = 10;
-
const double alum = 75.00;
-
const double vinyl = 57.00;
-
const double wood = 95.00;
-
const double comp = 45.00;
-
const double sshingle = 50.00;
-
const double dshingle = 75.00;
-
string siding_string;
-
string roofing_string;
-
ofstream house;
-
-
int main()
-
{
-
//Customer Input
-
house.open("C:\\Documents and Settings\\All Users\\Desktop\\house.dat");
-
house<<setw(23)<<" "<<setw(34)<<"Siding and Roofing Job Caculations"<<'\n';
-
while(next_customer=1)
-
{
-
cout<<"Please enter your name:"<<'\n';
-
cin.ignore();
-
cin.getline(cust_name, 40);
-
cout<<"Please enter the length (longer side of house) of the house in feet:"<<'\n';
-
cin>>length;
-
cout<<"Please enter the width (shorter side of house) of the house in feet:"<<'\n';
-
cin>>width;
-
cout<<"Please enter the number of stories:"<<'\n';
-
cin>>stories;
-
cout<<"Please enter the pitch of the roof. Enter first number. (Example 5/12 enter 5)"<<'\n';
-
cin>>pitch;
-
//Siding Menu
-
siding_type=0;
-
cout<<"\t Siding Type"<<'\n';
-
cout<<"\t \t (1) Aluminum Siding"<<'\n';
-
cout<<"\t \t (2) Vinyl Siding"<<'\n';
-
cout<<"\t \t (3) Wood Siding"<<'\n';
-
cout<<"\t \t (4) Composite Siding"<<'\n';
-
cout<<"\t \t \t Enter the number of the siding type:"<<'\n';
-
cin>>siding_type;
-
if(siding_type<1 || siding_type>4)
-
{
-
cout<<"Invalid entry"<<'\n';
-
cout<<"Enter 1,2,3, or 4"<<'\n';
-
cin>>siding_type;
-
}
-
//Roofing Menu
-
roofing_type=0;
-
cout<<"\t Roofing Type"<<'\n';
-
cout<<"\t \t (1) Standard Shingle"<<'\n';
-
cout<<"\t \t (2) Designer Shingle"<<'\n';;
-
cout<<"\t \t \t Enter the number of the siding type:"<<'\n';
-
cin>>roofing_type;
-
if(roofing_type<1 || roofing_type>2)
-
{
-
cout<<"Invalid entry"<<'\n';
-
cout<<"Enter 1 or 2"<<'\n';
-
cin>>roofing_type;
-
}
-
//Siding Cost Caculations
-
if(siding_type==1)
-
{
-
siding_cost = alum;
-
siding_string = "Aluminum";
-
}
-
if(siding_type==2)
-
{
-
siding_cost = vinyl;
-
siding_string = "Vinyl";
-
}
-
if(siding_type==3)
-
{
-
siding_cost = wood;
-
siding_string = "Wood";
-
}
-
if(siding_type==4)
-
{
-
siding_cost = comp;
-
siding_string = "Composite";
-
}
-
-
//Siding Cost Caculations
-
if(roofing_type==1)
-
{
-
roofing_cost = sshingle;
-
roofing_string = "Standard";
-
}
-
if(roofing_type==2)
-
{
-
roofing_cost = dshingle;
-
roofing_string = "Designer";
-
}
-
-
//Area Caculations
-
pitch=triangle_1;
-
triangle_height = pow(triangle_1,2) - pow(triangle_2,2);
-
triangle_width = 2 * triangle_1 * triangle_2;
-
triangle = sqrt(pow(triangle_height,2) + pow(triangle_width,2));
-
triangle_area = triangle *2;
-
sides = (width*2 + length*2) * height;
-
area_siding = sides + triangle_area;
-
siding_squares = area_siding/100;
-
-
roof_width = pow(height,2) + pow(width/.5,2);
-
area_roofing = (roof_width * length) * 2;
-
roofing_squares = area_roofing/100;
-
-
//Cost Caculations
-
total_siding_cost = siding_squares * siding_cost * 1.05;
-
total_roofing_cost = roofing_squares * roofing_cost * 1.05;
-
total_cost = total_siding_cost + total_roofing_cost;
-
-
//Output
-
house<<setw(5)<<" "<<setw(14)<<"Customer Name:"<<setw(1)<<" "<<setw(40)<<cust_name<<'\n';
-
house<<setw(5)<<" "<<setw(13)<<"Shingle Type:"<<setw(2)<<" "<<setw(40)<<roofing_type<<'\n';
-
house<<setw(5)<<" "<<setw(13)<<"Roof Squares:"<<setw(2)<<" "<<setw(40)<<roofing_squares<<'\n';
-
house<<setw(5)<<" "<<setw(10)<<"Roof Cost:"<<setw(5)<<" "<<setw(40)<<roofing_cost<<'\n';
-
house<<setw(5)<<" "<<setw(12)<<"Siding Type:"<<setw(3)<<" "<<setw(40)<<siding_type<<'\n';
-
house<<setw(5)<<" "<<setw(15)<<"Siding Squares:"<<setw(1)<<" "<<setw(40)<<siding_squares<<'\n';
-
house<<setw(5)<<" "<<setw(12)<<"Siding Cost:"<<setw(3)<<" "<<setw(40)<<siding_cost<<'\n';
-
house<<setw(5)<<" "<<setw(11)<<"Total Cost:"<<setw(4)<<" "<<setw(40)<<total_cost<<'\n';
-
house<<setw(80)<<"********************************************************************************"<<'\n';
-
-
//Next Customer
-
cout<<"Do you need caculations for another customer? (1 for Yes, 0 for No)"<<'\n';
-
cin>>next_customer;
-
}
-
}
-
system("PAUSE");
-
return 0;
-
}
Also I am suppose to round up the squares for the siding and roofing how do I go about doing that? Thanks.
1 1189
Well, I see a few things. First of all, you use these headers: - #include <iostream.h>
-
#include <stdlib.h>
-
#include <fstream>
-
#include <string>
-
#include <iomanip>
-
#include <math.h>
-
The .h is a depricated type - you should just have '#include <iostream>'. Also, you are using C++, not C, so get rid of stdlib.h. I'm not sure you need to use any of the C functions, but if you do, I'd go for the cstdlib library.
After that, your code should compile. If it doesn't, I'm guessing it is because of the system() function's return type being an int, and you not receiving anything back from it. -
system("PAUSE");
-
return 0;
-
}
I'd recommend getting your current code working before you look at the rounding.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: redneck_kiwi |
last post by:
Hi all:
I have a really weird problem. I am developing a customer catalog
system for my company and as such have delved into sessions for
authentication and access levels. So far, I have managed...
|
by: NanQuan |
last post by:
I'm hoping someone can help me solve this error since I am at a total
loss here. Usually I don't bother posting on any forums or groups on
the internet and prefer to solve stuff myself but this is...
|
by: amit |
last post by:
I am trying to compile the sample program genwin.sqc, using nsqlprep
which is used to precompile embedded sql in C. I am getting weird
errors and that is because windows.h is included in the...
|
by: Kathy Houtami |
last post by:
Hi there
I've been encountered with weird compile error using Access 97.
The error message is "Member or data member is not found" and it
highlighted a line of code that has not be changed and...
|
by: gh0st54 |
last post by:
Hi
I have a weird javascript error that only happens on my live server
when i open the page http://www.imrated.co.uk/reg.aspx
i get the error 'Problems with this page ... blablabla
Line : 3...
|
by: Alan Silver |
last post by:
Hello,
I have two weird problems here. I have a master page file that works
absolutely fine. When I load it up in VWD, I get a couple of weird (to
me) errors.
First, I get the error...
|
by: P Pulkkinen |
last post by:
Dear all,
sorry, i know this code is far little too long to debug here, but there is
really annoying logical error. If someone debugs this, I really offer warm
virtual handshake.
What this...
|
by: dtschoepe |
last post by:
Hi,
I am working on a project for school and I am trying to get my head
around something weird. I have a function setup which is used to get
an input from stdin and a piece of memory is created...
|
by: =?Utf-8?B?amVmZmVyeQ==?= |
last post by:
i need help with a combo box and this same code works on my first tab with a
combo box. The error or problem i have is this code causes an index out of
range error when i run it on my second combo...
|
by: d3vkit |
last post by:
I recently had a friend pass along some web work for me; a simple update. I for some reason decided I would do some overhauling of the page (he had been doing straight html and I figured some php...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |