• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1033
  • Last Modified:

% sign on the Miracle C Compiler

I want to give you all heads up. The Kudler Fine Foods Tax Calculator question is homework for sure. It is college or technical homework. The reason how I know is because I am in the middle of a class right now and that is our assignment. I am having problems with it but I seem to see a lot of questions on how to build a tax calculator. My intentions for being here is simple. I want to learn and since I am a visual learner it is way harder for me to asertain reading it. I do not want anyone to write the code for me, the questions I have are of specific nature. I hope this clears my intentions. If it seems like I am asking for more than that I am positively sure that I will be told about it, but keep in mind I am a beginner and if I am to learn it is by asking questions. All I ask is for a little help or guidance, no short cuts.

This is my first question
The significance in the percent sign. When I write 7.25% in the case staement it is in error.
here is what it looks like-       case Del Mar:
                                                        rate = 7.25%;
                                                        break;
Now, since 7.25 is laready being multiplied by the total which is 125.00 in the program, is the percent sign throwing the compiler off becase it is not needed, or am I missing or over writing the lines? Thank you
                                                                                         Rob
0
Shadow-Ninja
Asked:
Shadow-Ninja
1 Solution
 
duffman76Commented:
The percent sign is not necessary if you want to show a rate of 7.25% you can show it as rate=.0725.  Symbols such as %,$,& always have a different meaning in programming.  % is usually used to call a variable name such as %variablename% in code but it can be used for other things.  Hope this helps.
0
 
Infinity08Commented:
>>                                                         rate = 7.25%;

duffman76 is right of course, but I wanted to add this : rate is a floating point value (I hope), and was either defined like this :

        float rate;

or like this :

        double rate;

(or one of their "specializations").

A floating point value is just what it says : a value. It says nothing about what the value really means - it could be a price (in dollars), it could be the amount of fuel in a tank (in liters), ... or it could be a percentage like in your case.

In other words, you never write :

        float price = 5.25 dollar;
        float price = 5.25 $;
        double amount = 21.23 liter;
        double rate = 7.25 %;

Neither of the above are valid. Instead, you use :

        float price = 5.25;
        double amount = 21.23;
        double rate = 7.25;

and write the rest of the code, assuming that the price is in dollars, the amount in liters, and the rate is a percentage.

The exact meaning of the value is up to you, the programmer, to implement correctly in the code. Properly naming the value ("rate" in your case is good) can help a lot in clarifying what the value means.
0
 
grg99Commented:
The compiler knows nothing about the percent sign meaning "percent".  So you have to write:

float percent;

percent = 0.075;

or a little bit clearer:


float percent;

percent = 7.5 / 100.0;

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now