473,396 Members | 1,764 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.

C++ int main error while compiling and two different errors.

I am new to C++ and I am suppose to write a program in which the pc takes 5 values from a file called Values.in.txt and prints out

Assessed Value.........................XXXXXX.XX
Total Taxable Amount @33% Assessed Value.....XXXXXX.XX
Average Taxable Amount.......................XXXXXX.XX
Tax Rate for each $100.00.........................3.07
Total Property Tax:

After I compile it I get this error

sampletest.cpp: In function âint main()â:
sampletest.cpp:42: error: âhomevalueâ was not declared in this scope
sampletest.cpp:42: error: expected â;â before numeric constant

My Code is as follows

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4. #include <iomanip>
  5. #include <string> 
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.  
  12.     ifstream inFile;
  13.         ofstream outFile; 
  14.     double homevalue1, homevalue2, homevalue3, homevalue4, homevalue5;
  15.     double assessedvalue;
  16.     double taxableamount;
  17.     double avgtaxamt;
  18.     double taxrate;
  19.     double propertytax;
  20.  
  21.     inFile.open ("Values.in.txt");
  22.     outFile.open ( "Values.out");
  23.  
  24.     outFile << fixed << showpoint;
  25.         outFile << setprecision(2); 
  26.  
  27.     cout << "Calculating Data" << endl;
  28.  
  29.     inFile >> homevalue1 >> homevalue2 >> homevalue3
  30.            >> homevalue4 >> homevalue5;
  31.  
  32.  
  33.  
  34.     homevalue1 = 125.0;
  35.     homevalue2 = 130.0;
  36.     homevalue3 = 135.0;
  37.     homevalue4 = 140.0;
  38.     homevalue5 = 145.0;
  39.  
  40.  
  41.  
  42.     assessedvalue = homevalue1 + homevalue2 + homevalue3 + homevalue4 + homevalue 5;
  43.  
  44.     taxableamount = assessedvalue / 3;
  45.  
  46.     avgtaxamt = taxableamount / 5;
  47.  
  48.     taxrate = 3.07;
  49.  
  50.     propertytax = taxableamount * taxrate / 100;
  51.  
  52.  
  53.  
  54.     outFile << "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"
  55.                 << "-*-*-*-*-*-*-*-*-*-*-*-*-*" << endl;
  56.  
  57.  
  58.     outFile << setfill('.') << left << setw(35) << "Total Assessed Value: " 
  59.                 << right << " " << assessedvalue << endl;
  60.  
  61.  
  62.     outFile << left << setw(35) << "Total Taxable Amount @33% Assessed Value: "    
  63.         << setfill(' ') << right << setw(10) << taxableamount << endl;
  64.  
  65.     outFile << setfill('.') << left << setw(35) << "Average Taxable Amount: "
  66.         << setfill(' ') << right << avgtaxamt << endl;                // Add setw(8)
  67.  
  68.  
  69.     outFile << setfill('.') << left << setw(35) << "Tax rate for each 100 dollars: "
  70.         << setfill(' ') << right << setw(9) << taxrate << endl;
  71.  
  72.  
  73.     outFile << setfill('.') << left << setw(35) << "Total Property Tax: "
  74.         << setfill(' ') << right << propertytax << endl;
  75.  
  76.  
  77.         inFile.close(); 
  78.                 outFile.close();
  79.  
  80.  
  81.  
  82.     return 0;
  83.  
  84.  
  85. }
  86.  
  87.  
Sep 22 '14 #1
4 1359
weaknessforcats
9,208 Expert Mod 8TB
There's this:

Expand|Select|Wrap|Line Numbers
  1. assessedvalue = homevalue1 + homevalue2 + homevalue3 + homevalue4 + homevalue 5;
  2.  
The compiler thinks homevalue is the variable and the 5 s a syntax error. Remove the space.
Sep 22 '14 #2
Ok besides the space what do I have to do? I declared homevalue1-4
Sep 23 '14 #3
weaknessforcats
9,208 Expert Mod 8TB
What do you mean?

Did making that change allow your code to compile?
Sep 23 '14 #4
Nevermind yes it did thank you!!
Sep 24 '14 #5

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

Similar topics

0
by: Matt | last post by:
Just out of the blue all of my code has given a 'Could not instantiate the resource processor.' error on compiling. This apparently means your installation of VS .Net has lost the plot. So I've...
3
by: Baloff | last post by:
Hello this code is putting our errors which are diffecult for me to fix, I have been thinking about it for a while now... thanks for helping ...
2
by: Keith Bottner | last post by:
I just reinstalled my system and am in the process of getting PostgreSQL up and running again. During compilation of Postgres I received the following error: .... checking for main in...
4
by: Gary Wessle | last post by:
Hi I have been trying to find out the reason for this error for an 1hr, please look at it for me. thanks **************** error **************** $ make; ./proj g++ -gdwarf-2 -c -o...
8
by: maverick | last post by:
Hello I am getting an error when i am trying to instantiate an object of the template based class #include "foo.h" int main() {
3
by: Gary Wessle | last post by:
Hi I tried so long, so many ways to find out why this code is not compiling, I appreciate any help with it, thank you ****************************************************************...
1
by: kumarangopi | last post by:
Iam working with graphics.I wrote a pgogram in turbo c for graphics.I need to run on Freebsd system, so installed SDL and trying.when i give make in sdl_image folder /usr/lib/crt1.o undefined...
6
by: Gaijinco | last post by:
I'm having a weird error compiling a multiple file project: I have three files: tortuga.h where I have declared 5 global variables and prototypes for some functions. tortuga.cpp where I...
13
by: Albert | last post by:
Hi I'm using the lcc compiler for win32. I tried compiling a program but there's an error stating: "cpp: Can't open input file clrscr()" I don't get it - I've included <tcconio.h>. (strange why...
6
by: JR | last post by:
The code below compiles and runs perfectly in Windows XP Pro, Using MS VS 2005. If I compile with g++ (cygwin) using the following command line: g++ -pedantic -Weffc++ -Wall -Wctor-dtor-privacy ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...

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.