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\ste pha~1\desktop\p rogra~3.cpp:160 : ANSI C++ forbids declaration `system' with no type
c:\docume~1\ste pha~1\desktop\p rogra~3.cpp:160 : `int system' redeclared as different kind of symbol
C:\DEV-C_~1\Include\st dlib.h:283: previous declaration of `int system(const char *)'
c:\docume~1\ste pha~1\desktop\p rogra~3.cpp:160 : initialization to `int' from `const char *' lacks a cast
c:\docume~1\ste pha~1\desktop\p rogra~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 1201 sicarie 4,677
Recognized Expert Moderator Specialist
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 to get a
working system just about finished.
I am building an interface for our customer service folks to use to
manage registered customers and am seeing some weird behavior.
|
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 a total
mistery.
I have a function inside an ASP page as a result of which I get the
following error message:
Microsoft VBScript compilation error '800a03ea'
|
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 genwin.sqc
file. I am using
Setting the lib and include path:
set INCLUDE=C:\Program Files\Microsoft SQL
Server\80\Tools\DevTools\include;C:\Program Files\Microsoft SQL
Server\80\Tools\DevTools\Samples\esqlc;%include%
|
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 has been
compiled with no error for days.
The code was Me.CircuitQualifier.Requery
|
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
Char : 1
Error:Syntax error
| |
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 "Unrecognized tag prefix or device filter 'asp'"
on the third line shown below...
<head runat="server">
|
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 code SHOULD do:
- read new (=updated) licensetext from file $license_path
then
- read and modify recursively all files from $current_dir, replacing old
|
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 on the heap using
malloc. This input is then run through a regex and another test. The
result is passed back as a char pointer to the program for further
processing
The first time I call this function, it performs normally. However,
|
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 box:
(errored code) Select Case ComboBox2.text
Case Is ="Execute Program"
'code to execute program here
Case Is ="Other Command that executes code at a certain time"
' code below the same as above except that it works
But not my first(this...
|
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 would make things MUCH more manageable, especially with the pictures).
So, I set to work doing what I normally do for all my site, create the index page with a switch to stick different content in the main part of the page depending on variables passed...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |