snipt

Ctrl+h for KB shortcuts
Notice: Snipt is moving away from free accounts on May 1st, 2014. Read more about the transition here.
#31322

Java

salestax

1
2
3
4
5
6
7
public class SalesTax {
   public static void main(String[] args) {
     double purchaseAmount = 197.55;
double tax = purchaseAmount * 0.06;
System.out.println((int)(tax * 100) / 100.00);
}
}
https://snipt.net/embed/6d28fd5c456742f78bb317102962f5ea/
https://snipt.net/raw/6d28fd5c456742f78bb317102962f5ea/
6d28fd5c456742f78bb317102962f5ea
java
Java
8
2014-03-12T10:14:17
True
False
/api/public/snipt/31322/
salestax
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SalesTax</span> <span class="o">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="n">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="kt">double</span> <span class="n">purchaseAmount</span> <span class="o">=</span> <span class="mf">197.55</span><span class="o">;</span> </span><span id="L-4"><a name="L-4"></a><span class="kt">double</span> <span class="n">tax</span> <span class="o">=</span> <span class="n">purchaseAmount</span> <span class="o">*</span> <span class="mf">0.06</span><span class="o">;</span> </span><span id="L-5"><a name="L-5"></a><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">((</span><span class="kt">int</span><span class="o">)(</span><span class="n">tax</span> <span class="o">*</span> <span class="mi">100</span><span class="o">)</span> <span class="o">/</span> <span class="mf">100.00</span><span class="o">);</span> </span><span id="L-6"><a name="L-6"></a><span class="o">}</span> </span><span id="L-7"><a name="L-7"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
salestax