473,803 Members | 4,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weird Error

32 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream.h>
  2. #include <stdlib.h>
  3. #include <fstream>
  4. #include <string>
  5. #include <iomanip>
  6. #include <math.h>
  7. using namespace std;
  8.  
  9. char cust_name[40];
  10. double length;
  11. double width;
  12. double stories;
  13. double pitch;
  14. double total_cost;
  15. double siding_cost;
  16. double roofing_cost;
  17. double area_siding;
  18. double area_roofing;
  19. double roof_width;
  20. double roofing_squares;
  21. double siding_squares;
  22. double triangle_1;
  23. double triangle_2;
  24. double triangle_height;
  25. double triangle_width;
  26. double triangle_area;
  27. double triangle;
  28. double sides;
  29. double total_roofing_cost;
  30. double total_siding_cost;
  31. int siding_type;
  32. int roofing_type;
  33. int next_customer;
  34. const double height = 10;
  35. const double alum = 75.00;
  36. const double vinyl = 57.00;
  37. const double wood = 95.00;
  38. const double comp = 45.00;
  39. const double sshingle = 50.00;
  40. const double dshingle = 75.00;
  41. string siding_string;
  42. string roofing_string;
  43. ofstream house;
  44.  
  45. int main()
  46. {
  47. //Customer Input
  48. house.open("C:\\Documents and Settings\\All Users\\Desktop\\house.dat");
  49. house<<setw(23)<<" "<<setw(34)<<"Siding and Roofing Job Caculations"<<'\n';
  50. while(next_customer=1)
  51. {
  52. cout<<"Please enter your name:"<<'\n';
  53. cin.ignore();
  54. cin.getline(cust_name, 40);
  55. cout<<"Please enter the length (longer side of house) of the house in feet:"<<'\n';
  56. cin>>length;
  57. cout<<"Please enter the width (shorter side of house) of the house in feet:"<<'\n';
  58. cin>>width;
  59. cout<<"Please enter the number of stories:"<<'\n';
  60. cin>>stories;
  61. cout<<"Please enter the pitch of the roof. Enter first number. (Example 5/12 enter 5)"<<'\n';
  62. cin>>pitch;
  63. //Siding Menu
  64. siding_type=0;
  65. cout<<"\t Siding Type"<<'\n';
  66. cout<<"\t \t (1) Aluminum Siding"<<'\n';
  67. cout<<"\t \t (2) Vinyl Siding"<<'\n';
  68. cout<<"\t \t (3) Wood Siding"<<'\n';
  69. cout<<"\t \t (4) Composite Siding"<<'\n';
  70. cout<<"\t \t \t Enter the number of the siding type:"<<'\n';
  71. cin>>siding_type;
  72. if(siding_type<1 || siding_type>4)
  73. {
  74. cout<<"Invalid entry"<<'\n';
  75. cout<<"Enter 1,2,3, or 4"<<'\n';
  76. cin>>siding_type;
  77. }
  78. //Roofing Menu
  79. roofing_type=0;
  80. cout<<"\t Roofing Type"<<'\n';
  81. cout<<"\t \t (1) Standard Shingle"<<'\n';
  82. cout<<"\t \t (2) Designer Shingle"<<'\n';;
  83. cout<<"\t \t \t Enter the number of the siding type:"<<'\n';
  84. cin>>roofing_type;
  85. if(roofing_type<1 || roofing_type>2)
  86. {
  87. cout<<"Invalid entry"<<'\n';
  88. cout<<"Enter 1 or 2"<<'\n';
  89. cin>>roofing_type;
  90. }
  91. //Siding Cost Caculations
  92. if(siding_type==1)
  93. {
  94. siding_cost = alum;
  95. siding_string = "Aluminum";
  96. }
  97. if(siding_type==2)
  98. {
  99. siding_cost = vinyl;
  100. siding_string = "Vinyl";
  101. }
  102. if(siding_type==3)
  103. {
  104. siding_cost = wood;
  105. siding_string = "Wood";
  106. }
  107. if(siding_type==4)
  108. {
  109. siding_cost = comp;
  110. siding_string = "Composite";
  111. }
  112.  
  113. //Siding Cost Caculations
  114. if(roofing_type==1)
  115. {
  116. roofing_cost = sshingle;
  117. roofing_string = "Standard";
  118. }
  119. if(roofing_type==2)
  120. {
  121. roofing_cost = dshingle;
  122. roofing_string = "Designer";
  123. }
  124.  
  125. //Area Caculations
  126. pitch=triangle_1;
  127. triangle_height = pow(triangle_1,2) - pow(triangle_2,2);
  128. triangle_width = 2 * triangle_1 * triangle_2;
  129. triangle = sqrt(pow(triangle_height,2) + pow(triangle_width,2));
  130. triangle_area = triangle *2;
  131. sides = (width*2 + length*2) * height;
  132. area_siding = sides + triangle_area;
  133. siding_squares = area_siding/100;
  134.  
  135. roof_width = pow(height,2) + pow(width/.5,2);
  136. area_roofing = (roof_width * length) * 2;
  137. roofing_squares = area_roofing/100;
  138.  
  139. //Cost Caculations
  140. total_siding_cost = siding_squares * siding_cost * 1.05;
  141. total_roofing_cost = roofing_squares * roofing_cost * 1.05;
  142. total_cost = total_siding_cost + total_roofing_cost;
  143.  
  144. //Output
  145. house<<setw(5)<<" "<<setw(14)<<"Customer Name:"<<setw(1)<<" "<<setw(40)<<cust_name<<'\n';
  146. house<<setw(5)<<" "<<setw(13)<<"Shingle Type:"<<setw(2)<<" "<<setw(40)<<roofing_type<<'\n';
  147. house<<setw(5)<<" "<<setw(13)<<"Roof Squares:"<<setw(2)<<" "<<setw(40)<<roofing_squares<<'\n';
  148. house<<setw(5)<<" "<<setw(10)<<"Roof Cost:"<<setw(5)<<" "<<setw(40)<<roofing_cost<<'\n';
  149. house<<setw(5)<<" "<<setw(12)<<"Siding Type:"<<setw(3)<<" "<<setw(40)<<siding_type<<'\n';
  150. house<<setw(5)<<" "<<setw(15)<<"Siding Squares:"<<setw(1)<<" "<<setw(40)<<siding_squares<<'\n';
  151. house<<setw(5)<<" "<<setw(12)<<"Siding Cost:"<<setw(3)<<" "<<setw(40)<<siding_cost<<'\n';
  152. house<<setw(5)<<" "<<setw(11)<<"Total Cost:"<<setw(4)<<" "<<setw(40)<<total_cost<<'\n';
  153. house<<setw(80)<<"********************************************************************************"<<'\n';
  154.  
  155. //Next Customer
  156. cout<<"Do you need caculations for another customer? (1 for Yes, 0 for No)"<<'\n';
  157. cin>>next_customer;
  158. }
  159. }
  160.       system("PAUSE");
  161.       return 0;
  162. }
Also I am suppose to round up the squares for the siding and roofing how do I go about doing that? Thanks.
Dec 13 '07 #1
1 1201
sicarie
4,677 Recognized Expert Moderator Specialist
Well, I see a few things. First of all, you use these headers:
Expand|Select|Wrap|Line Numbers
  1. #include <iostream.h>
  2. #include <stdlib.h>
  3. #include <fstream>
  4. #include <string>
  5. #include <iomanip>
  6. #include <math.h>
  7.  
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.
Expand|Select|Wrap|Line Numbers
  1.        system("PAUSE");
  2.       return 0;
  3. }
I'd recommend getting your current code working before you look at the rounding.
Dec 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2081
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.
5
14630
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'
1
2787
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%
2
2537
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
6
1552
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
0
2065
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">
0
1835
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
7
2015
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,
6
1877
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...
4
2626
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...
0
10546
Oralloy
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...
1
10292
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,...
0
10068
tracyyun
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...
1
7603
isladogs
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...
0
6841
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();...
0
5498
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...
0
5627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
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
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.