87 lines
5.5 KiB
HTML
87 lines
5.5 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Bonus.java</title>
|
||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||
|
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||
|
table {color: #888888; background-color: #313335; font-family: monospace}
|
||
|
.ST1 {color: #808080; font-family: monospace; font-weight: bold}
|
||
|
.comment {color: #808080}
|
||
|
.whitespace {color: #505050}
|
||
|
.ST2 {color: #ffc66d; font-family: monospace; font-style: italic}
|
||
|
.ST4 {color: #9876aa; font-family: monospace; font-style: italic}
|
||
|
.number {color: #6897bb}
|
||
|
.string {color: #6a8759}
|
||
|
.ST0 {color: #287bde}
|
||
|
.ST3 {font-family: monospace; font-style: italic}
|
||
|
.literal {color: #cc7832}
|
||
|
-->
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<table width="100%"><tr><td align="center">/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Bonus.java</td></tr></table>
|
||
|
<pre>
|
||
|
<span class="comment">/*</span>
|
||
|
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
|
||
|
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
|
||
|
<span class="comment"> */</span>
|
||
|
<span class="literal">package</span> com.calebfontenot.lab7_calebfontenot;
|
||
|
|
||
|
<span class="literal">import</span> java.util.Scanner;
|
||
|
<span class="literal">import</span> java.text.NumberFormat;
|
||
|
|
||
|
<span class="comment">/**</span>
|
||
|
<span class="comment"> *</span>
|
||
|
<span class="comment"> * </span><span class="ST1">@author</span> <span class="comment">caleb</span>
|
||
|
<span class="comment">*/</span>
|
||
|
<span class="literal">public</span> <span class="literal">class</span> Bonus {
|
||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST2">main</span>(String[] args)
|
||
|
{
|
||
|
<span class="comment">//Setup currency formatter</span>
|
||
|
NumberFormat defaultFormat = NumberFormat.<span class="ST3">getCurrencyInstance</span>();
|
||
|
<span class="comment">// Create scanner</span>
|
||
|
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST4">in</span>);
|
||
|
|
||
|
<span class="comment">// Setup vars</span>
|
||
|
String lastName,
|
||
|
firstName;
|
||
|
<span class="literal">double</span> thisYearsUnits,
|
||
|
lastYearsUnits,
|
||
|
bonus = <span class="number">0</span>;
|
||
|
|
||
|
<span class="comment">// Prompt for input</span>
|
||
|
System.<span class="ST4">out</span>.print(<span class="string">"</span><span class="string">Enter last name: </span><span class="string">"</span>);
|
||
|
lastName = input.nextLine();
|
||
|
System.<span class="ST4">out</span>.print(<span class="string">"</span><span class="string">Enter first name: </span><span class="string">"</span>);
|
||
|
firstName = input.nextLine();
|
||
|
System.<span class="ST4">out</span>.print(<span class="string">"</span><span class="string">Enter this year's units: </span><span class="string">"</span>);
|
||
|
thisYearsUnits = input.nextDouble();
|
||
|
System.<span class="ST4">out</span>.print(<span class="string">"</span><span class="string">Enter last year's units: </span><span class="string">"</span>);
|
||
|
lastYearsUnits = input.nextDouble();
|
||
|
|
||
|
<span class="comment">// Compute!</span>
|
||
|
<span class="literal">if</span> (thisYearsUnits > lastYearsUnits) {
|
||
|
<span class="literal">if</span> (<span class="number">1000</span> > thisYearsUnits) <span class="comment">// If thisYearsUnits is less than 1000</span>
|
||
|
bonus = <span class="number">25</span>;
|
||
|
<span class="literal">else</span> <span class="literal">if</span> (thisYearsUnits > <span class="number">1000</span> && thisYearsUnits < <span class="number">3000</span>) <span class="comment">// If thisYearsUnits is more than 1000, but less than 3000</span>
|
||
|
bonus = <span class="number">50</span>;
|
||
|
<span class="literal">else</span> <span class="literal">if</span> (thisYearsUnits > <span class="number">3000</span> && thisYearsUnits < <span class="number">6000</span>) <span class="comment">// If thisYearsUnits is more than 3000, but less than 6000</span>
|
||
|
bonus = <span class="number">100</span>;
|
||
|
<span class="literal">else</span> <span class="literal">if</span> (thisYearsUnits > <span class="number">6000</span>) <span class="comment">// 6000 and up</span>
|
||
|
bonus = <span class="number">200</span>;
|
||
|
}
|
||
|
|
||
|
<span class="comment">// Output</span>
|
||
|
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Employee Name: </span><span class="string">"</span>);
|
||
|
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="literal">\t</span><span class="string">"</span>+ lastName + <span class="string">"</span><span class="string">, </span><span class="string">"</span> + firstName);
|
||
|
System.<span class="ST4">out</span>.println(<span class="string">"</span><span class="string">Bonus is </span><span class="string">"</span>+ defaultFormat.format(bonus));
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
</pre></body>
|
||
|
</html>
|