473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Weird Error

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

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 1189
sicarie
4,677 Expert Mod 4TB
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
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...
5
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...
1
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...
2
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...
6
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...
0
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...
0
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...
7
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...
6
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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,...
0
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...
0
agi2029
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,...
0
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...

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.