• C

Tax calculator with menu

This is my project and this is what I have so far, it wa able to compile but there is a linker error.  
Project: Tax calculator that multiply the tax rate by the purchase amount 100.00.  Then I have to modify the
simple tax calculator by adding a menu.  Itried to combine the two in one project and was able to compile, but have a linker error:

This is what I have
#include<stdio.h>
/*DelMar = 7.25 %/
/*Encinitas = 7.50%/
/*La Jolla = 7.75%/

printf("Tax Calculator\n");
//prompt the user to enter amounts
printf("\nSelect (a) calculate tax\n");
printf("\nSelect (0) to exit\n");
scanf("%c", &userSelect);
tax=price*0.0725;// Del Mar tax calculation
tax=price*0.0750;//Encinitas tax calculation
tax=price*0.0775;//La Jolla tax calculation
switch (task){
{
 case 1: DelMar:
      {      
      rate = 7.25;
      break;
      }
 case Encinitas:{
      rate = 7.5;
      break;
     
 case La Jolla:
      rate = 7.75;
      break;
     
}
int main()
{
     int task;
     char c;
     float myAmount;
     do
     {
         
nelliaAsked:
Who is Participating?
 
cwwkieCommented:
On line 2 you start a comment, which is not ended,

/*DelMar = 7.25 %/

(it should end with a */  )

So the whole file is treated as a comment, and nothing gets compiled. A compiler *should* give an error about the comment which is not ended, but it seems your compiler does not.
0
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi nellia,

You should have several compilation errors.  You have unbalance { } all over the place.  The linker error is probably coming from the fact that the program won't compile so your object file has no main() function.

Good Luck!
Kent
0
 
nelliaAuthor Commented:
But it actually compiled, gave me a linker error only.  Usually I get a compiler error.  Unbalance?
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
Kent OlsenData Warehouse Architect / DBACommented:
Hi nellia,

Check out main.  You have two lefts, the second one initiates an incomplete do/while.

You've got code outside of any function.  The line:

printf("Tax Calculator\n");

and those following it can never get executed.


Kent
0
 
nelliaAuthor Commented:
Linker Error (Severity 4)
      Module "cruntime.asm" in file "c:\program files\miracle c\ccl.lib "
      references unresolved external "_main"
      at offset 0092H in segment "_text".

Is what I am getting
0
 
Infinity08Commented:
That is because of what Kdo said : your main .c file didn't compile, so when the linker looked for it it couldn't find the compiled object file for it ... hence the error.

What compiler are you using ?

Start by putting your code INSIDE the main() function ...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.