473,402 Members | 2,064 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,402 software developers and data experts.

Parce Error Help

Can anyone tell me why this won't compile?


#include <stdio.h>
#include <ctype.h>

void main ()
{

/* Variables defined with corresponding tax rates. */
float fTaxRateDelMar = .0725;
float fTaxRateEncinitas = .075;
float fTaxRateLaJolla = .0775;

/* Variable defined for user inputed dollar amount to be taxed.*/
float fDollarAmount = 0.0;
printf("\nWelcome to Kudler Fine Foods.\n");
printf("\nPlease enter the subtotal to be taxed: ");
scanf ("%f", &fDollarAmount);


/* Check validity of user input (number) - return if input is invalid, continue if input is valid */
int i = isdigit(fDollarAmount);
while i==0
{
printf("\nPlease enter a valid number: ");
scanf ("%f", &fDollarAmount);
int i = isdigit(fDollarAmount);
}

/* Calculation variables defined and calculations accomplished. */
float fSalesTaxDelMar = fDollarAmount * fTaxRateDelMar;
float fSalesTaxEncinitas = fDollarAmount * fTaxRateEncinitas;
float fSalesTaxLaJolla = fDollarAmount * fTaxRateLaJolla;
float fTotalSaleDelMar = fDollarAmount + fSalesTaxDelMar;
float fTotalSaleEncinitas = fDollarAmount + fSalesTaxEncinitas;
float fTotalSaleLaJolla = fDollarAmount + fSalesTaxLaJolla;

/* Print statements to display the Sales Tax and Total Sale values. */
printf("\nThe sales tax on $%i at the Del Mar store is: $%.2f\n", fDollarAmount, fSalesTaxDelMar);
printf("\nThe sales tax on $%i at the Encinitas store is: $%.2f\n", fDollarAmount, fSalesTaxEncinitas);
printf("\nThe sales tax on $%i at the La Jolla store is: $%.2f\n", fDollarAmount, fSalesTaxLaJolla);

}
Aug 1 '07 #1
12 1727
Meetee
931 Expert Mod 512MB
Can anyone tell me why this won't compile?


#include <stdio.h>
#include <ctype.h>

void main ()
{

/* Variables defined with corresponding tax rates. */
float fTaxRateDelMar = .0725;
float fTaxRateEncinitas = .075;
float fTaxRateLaJolla = .0775;

/* Variable defined for user inputed dollar amount to be taxed.*/
float fDollarAmount = 0.0;
printf("\nWelcome to Kudler Fine Foods.\n");
printf("\nPlease enter the subtotal to be taxed: ");
scanf ("%f", &fDollarAmount);


/* Check validity of user input (number) - return if input is invalid, continue if input is valid */
int i = isdigit(fDollarAmount);
while i==0
{
printf("\nPlease enter a valid number: ");
scanf ("%f", &fDollarAmount);
int i = isdigit(fDollarAmount);
}

/* Calculation variables defined and calculations accomplished. */
float fSalesTaxDelMar = fDollarAmount * fTaxRateDelMar;
float fSalesTaxEncinitas = fDollarAmount * fTaxRateEncinitas;
float fSalesTaxLaJolla = fDollarAmount * fTaxRateLaJolla;
float fTotalSaleDelMar = fDollarAmount + fSalesTaxDelMar;
float fTotalSaleEncinitas = fDollarAmount + fSalesTaxEncinitas;
float fTotalSaleLaJolla = fDollarAmount + fSalesTaxLaJolla;

/* Print statements to display the Sales Tax and Total Sale values. */
printf("\nThe sales tax on $%i at the Del Mar store is: $%.2f\n", fDollarAmount, fSalesTaxDelMar);
printf("\nThe sales tax on $%i at the Encinitas store is: $%.2f\n", fDollarAmount, fSalesTaxEncinitas);
printf("\nThe sales tax on $%i at the La Jolla store is: $%.2f\n", fDollarAmount, fSalesTaxLaJolla);

}
After compiling you program, I found some errors, which I want you to correct.
Kindly change void main() to int main() and return 0; at the end of main function.
Also change while i==0 to while (i==0). This is a syntax error.

I am not aware of your program functionality. So I got output as
Welcome to Kudler Fine Foods.

Please enter the subtotal to be taxed:

So do the changes and ask if any problem.

Regards
Aug 1 '07 #2
After compiling you program, I found some errors, which I want you to correct.
Kindly change void main() to int main() and return 0; at the end of main function.
Also change while i==0 to while (i==0). This is a syntax error.

I am not aware of your program functionality. So I got output as
Welcome to Kudler Fine Foods.

Please enter the subtotal to be taxed:

So do the changes and ask if any problem.

Regards

I made the changes you suggested but I'm still getting the same parce error:

line 45: Parse Error, expecting `'}''
'int i = isdigit(fDollarAmount)'

Any idea what's causing it?
Aug 1 '07 #3
JosAH
11,448 Expert 8TB
.Kindly change void main() to int main() and return 0; at the end of main function.
Can we have this engraved on titanium plaques and nail them to the front door
of every possible C/C++ forum please?

kind regards,

Jos
Aug 1 '07 #4
Meetee
931 Expert Mod 512MB
I made the changes you suggested but I'm still getting the same parce error:

line 45: Parse Error, expecting `'}''
'int i = isdigit(fDollarAmount)'

Any idea what's causing it?
I think you have forgot to put "}" somewhere near 'int i = isdigit(fDollarAmount)' line. Kindly check that. You will have to check all "{" have it's "}".
Aug 1 '07 #5
Meetee
931 Expert Mod 512MB
Can we have this engraved on titanium plaques and nail them to the front door
of every possible C/C++ forum please?

kind regards,

Jos
Have I done anything wrong? Actually it was causing error. Kindly correct me if I am wrong.

Regards
Aug 1 '07 #6
JosAH
11,448 Expert 8TB
Have I done anything wrong? Actually it was causing error. Kindly correct me if I am wrong.

Regards
You haven't done anything wrong at all; as a matter of fact your statement is
1000% correct as per the definitiion in the Standard; I'd wish more people used
a proper int main() instead of that silly Microsoftism 'void main()'.

Hence the engraved plaques ;-)

kind regards,

Jos
Aug 1 '07 #7
Meetee
931 Expert Mod 512MB
You haven't done anything wrong at all; as a matter of fact your statement is
1000% correct as per the definitiion in the Standard; I'd wish more people used
a proper int main() instead of that silly Microsoftism 'void main()'.

Hence the engraved plaques ;-)

kind regards,

Jos
I see. I think your suggestion of plaques is not a bad idea..! lol

Regards
Aug 1 '07 #8
I think you have forgot to put "}" somewhere near 'int i = isdigit(fDollarAmount)' line. Kindly check that. You will have to check all "{" have it's "}".

I have checked them and that's what's driving me nuts. There are only 2 sets of "{ }" in the code - one set for the main function and one for the while loop and both complete sets are there.
Aug 1 '07 #9
JosAH
11,448 Expert 8TB
I have checked them and that's what's driving me nuts. There are only 2 sets of "{ }" in the code - one set for the main function and one for the while loop and both complete sets are there.
Care to post you code again? Because except for the "i == 0" instead of "(i == 0)"
there were no syntax errors in your code. You're on the wrong track or your code
is not what we see here.

kind regards,

Jos

ps. and put [ code ] before your code and [ /code ] afterwards (without the spaces).
Aug 1 '07 #10
weaknessforcats
9,208 Expert Mod 8TB
This is C.

In C all variables must be defined at the start of the function.

Only in C++ can you define variables in the middle of the code.
Aug 1 '07 #11
This is C.

In C all variables must be defined at the start of the function.

Only in C++ can you define variables in the middle of the code.

That was the problem, thanks.

Now that I got that working, anybody have any idea how I can validate that the user is entering a number and not a letter or special character?
Aug 2 '07 #12
weaknessforcats
9,208 Expert Mod 8TB
Now that I got that working, anybody have any idea how I can validate that the user is entering a number and not a letter or special character?
Yes. Start a new thread. When I see it I will respond.
Aug 2 '07 #13

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

Similar topics

4
by: dave | last post by:
Hello, I'm trying to get php authentication working on a test apache2 server prior to implementing it site wide. I'm authenticating against the system password file, and i'm getting a parce error...
0
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
2
by: Maurizio Amoroso | last post by:
.... DTSRun: Executing... DTSRun OnStart: DTSStep_DTSExecuteSQLTask_1 DTSRun OnStart: DTSStep_DTSExecuteSQLTask_2 DTSRun OnStart: DTSStep_DTSExecuteSQLTask_4 DTSRun OnStart:...
6
by: Rowan | last post by:
Hello, I have been trying to solve this problem for a couple of weeks now with no progress. I created a package that works when it runs from my computer but when it runs as a scheduled job, it...
8
by: Rene | last post by:
Hi, I'm spend many hour to fix this problem, read many articles about it but no article gave a solution. To isolate the problem I've created in IIS6 (WServer2003) a virtual directory test to...
5
by: xuatla | last post by:
Hi, I encountered the following compile error of c++ and hope to get your help. test2.cpp: In member function `CTest CTest::operator+=(CTest&)': test2.cpp:79: error: no match for 'operator='...
2
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
1
by: kvarada | last post by:
Hello Experts, I am building my application on WinNT.4.0_i386_MSVC.7.1 platform. When I build the application on a stand alone machine, it builds fine. But when I build the same application from a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
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...
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.