lab7
This commit is contained in:
parent
332733653b
commit
1c473a521a
BIN
lab7_CalebFontenot.zip
Normal file
BIN
lab7_CalebFontenot.zip
Normal file
Binary file not shown.
57
lab7_CalebFontenot/And1.html
Normal file
57
lab7_CalebFontenot/And1.html
Normal file
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>And1.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}
|
||||
.ST3 {color: #9876aa; font-family: monospace; font-style: italic}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.ST0 {color: #287bde}
|
||||
.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/And1.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="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> And1 {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST2">main</span>(String[] args)
|
||||
{
|
||||
System.<span class="ST3">out</span>.print(<span class="string">"</span><span class="string">please enter a number between 0 and 10: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> number = <span class="literal">new</span> Scanner(System.<span class="ST3">in</span>).nextInt();
|
||||
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> the &&is the AND operator which ANDs 2 operands</span>
|
||||
<span class="comment"> The ANDing evaluates to true if both of the operands of the AND are true</span>
|
||||
<span class="comment"> UNDERSTAND THIS AND &&, please</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">if</span> ( number >= <span class="number">0</span> && number <= <span class="number">10</span> )
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="string">thank you for entering number </span><span class="string">"</span> + number );
|
||||
<span class="literal">else</span>
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="string">"</span> + number + <span class="string">"</span><span class="string"> is not between 0 and 10! What's wrong with you man?</span><span class="string">"</span>);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
65
lab7_CalebFontenot/And2.html
Normal file
65
lab7_CalebFontenot/And2.html
Normal file
@ -0,0 +1,65 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>And2.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}
|
||||
.ST3 {color: #9876aa; font-family: monospace; font-style: italic}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.ST0 {color: #287bde}
|
||||
.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/And2.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="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> And2 {
|
||||
<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">// Create Scanner</span>
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST3">in</span>);
|
||||
|
||||
<span class="comment">// Setup vars</span>
|
||||
<span class="literal">int</span> number;
|
||||
|
||||
<span class="comment">// Prompt for input</span>
|
||||
System.<span class="ST3">out</span>.print(<span class="string">"</span><span class="string">Please enter a number that is divisable by 10 and greater than 100: </span><span class="string">"</span>);
|
||||
number = input.nextInt();
|
||||
|
||||
<span class="comment">// Compute</span>
|
||||
<span class="literal">if</span> ( number % <span class="number">10</span> == <span class="number">0</span> && number > <span class="number">100</span>)
|
||||
{
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">Thanks for entering number </span><span class="string">"</span> + number+ <span class="string">"</span><span class="string">!</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span>
|
||||
{
|
||||
System.<span class="ST3">out</span>.println(number + <span class="string">"</span><span class="string"> is not fufilling the request!</span><span class="string">"</span>);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
86
lab7_CalebFontenot/Bonus.html
Normal file
86
lab7_CalebFontenot/Bonus.html
Normal file
@ -0,0 +1,86 @@
|
||||
<!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>
|
45
lab7_CalebFontenot/Debug1.html
Normal file
45
lab7_CalebFontenot/Debug1.html
Normal file
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Debug1.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}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.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/Debug1.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> Debug1 {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
<span class="literal">int</span> i=<span class="number">1</span>, j=<span class="number">2</span>, k=<span class="number">3</span>;
|
||||
<span class="literal">if</span> (i < j && i < k && j < k)
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="string">i, j, and k are in increasing order</span><span class="string">"</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
92
lab7_CalebFontenot/DivisionQuiz.html
Normal file
92
lab7_CalebFontenot/DivisionQuiz.html
Normal file
@ -0,0 +1,92 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>DivisionQuiz.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}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.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/DivisionQuiz.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java 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="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> DivisionQuiz {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
<span class="comment">// Create scanner</span>
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.in);
|
||||
<span class="comment">// Setup variables</span>
|
||||
<span class="literal">int</span> number1,
|
||||
number2,
|
||||
answerQuotient,
|
||||
answerRemainder;
|
||||
<span class="literal">boolean</span> cheatMode = <span class="literal">false</span>; <span class="comment">// Used for debugging</span>
|
||||
|
||||
<span class="literal">while</span> (<span class="literal">true</span>) {
|
||||
<span class="comment">// Get random numbers between 1-100</span>
|
||||
number1 = (<span class="literal">int</span>) (Math.random() * <span class="number">100</span>);
|
||||
number2 = (<span class="literal">int</span>) (Math.random() * <span class="number">100</span>);
|
||||
|
||||
<span class="comment">// If number1 < number2, flip them</span>
|
||||
<span class="literal">if</span> (number1 < number2) {
|
||||
<span class="literal">int</span> tmp = number2;
|
||||
number2 = number1;
|
||||
number1 = tmp;
|
||||
}
|
||||
|
||||
<span class="comment">//Prompt</span>
|
||||
<span class="literal">if</span> (cheatMode == <span class="literal">true</span>) {
|
||||
System.out.println(<span class="string">"</span><span class="string">CHEAT MODE: the quotient of </span><span class="string">"</span> + number1 + <span class="string">"</span><span class="string"> / </span><span class="string">"</span> + number2 + <span class="string">"</span><span class="string"> is </span><span class="string">"</span> + (number1 / number2));
|
||||
}
|
||||
System.out.print(<span class="string">"</span><span class="string"> What is the quotient of </span><span class="string">"</span> + number1 + <span class="string">"</span><span class="string"> / </span><span class="string">"</span> + number2 + <span class="string">"</span><span class="string">? </span><span class="string">"</span>);
|
||||
answerQuotient = input.nextInt();
|
||||
<span class="literal">if</span> (cheatMode == <span class="literal">true</span>) {
|
||||
System.out.println(<span class="string">"</span><span class="string">CHEAT MODE: the remainder of </span><span class="string">"</span> + number1 + <span class="string">"</span><span class="string"> % </span><span class="string">"</span> + number2 + <span class="string">"</span><span class="string"> is </span><span class="string">"</span> + (number1 % number2));
|
||||
}
|
||||
System.out.print(<span class="string">"</span><span class="string"> What is the remainder of </span><span class="string">"</span> + number1 + <span class="string">"</span><span class="string"> / </span><span class="string">"</span> + number2 + <span class="string">"</span><span class="string">? </span><span class="string">"</span>);
|
||||
answerRemainder = input.nextInt();
|
||||
|
||||
<span class="comment">// Check if answers are correct</span>
|
||||
<span class="literal">if</span> ((number1 / number2) == answerQuotient) <span class="comment">//Checks the quotient</span>
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="string">You are correct about the quotient!</span><span class="string">"</span>);
|
||||
} <span class="literal">else</span> {
|
||||
System.out.println(<span class="string">"</span><span class="string">You are wrong about the quotient.</span><span class="string">"</span>);
|
||||
System.out.println(<span class="string">"</span><span class="string">The quotient of </span><span class="string">"</span> + number1 + <span class="string">"</span><span class="string"> / </span><span class="string">"</span> + number2 + <span class="string">"</span><span class="string"> is </span><span class="string">"</span> + (number1 / number2));
|
||||
}
|
||||
<span class="literal">if</span> ((number1 % number2) == answerRemainder) <span class="comment">//Checks the remainder</span>
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="string">You are correct about the remainder!</span><span class="string">"</span>);
|
||||
} <span class="literal">else</span> {
|
||||
System.out.println(<span class="string">"</span><span class="string">You are wrong about the remainder.</span><span class="string">"</span>);
|
||||
System.out.println(<span class="string">"</span><span class="string">The remainder of </span><span class="string">"</span> + number1 + <span class="string">"</span><span class="string"> % </span><span class="string">"</span> + number2 + <span class="string">"</span><span class="string"> is </span><span class="string">"</span> + (number1 % number2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
63
lab7_CalebFontenot/Not1.html
Normal file
63
lab7_CalebFontenot/Not1.html
Normal file
@ -0,0 +1,63 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Not1.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}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.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/Not1.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java 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="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> Not1 {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
System.out.print(<span class="string">"</span><span class="string">Please enter a number between 0 and 10: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> number = <span class="literal">new</span> Scanner(System.in).nextInt();
|
||||
<span class="comment">/* </span>
|
||||
<span class="comment"> The ! is the NOT operator which reverses a boolean expression.</span>
|
||||
<span class="comment"> If the expression is true, the not makes it false and vice-versa.</span>
|
||||
|
||||
<span class="comment"> the || is the OR operator which ORs 2 operands</span>
|
||||
<span class="comment"> This is the equivalent AND1 by using OR and NOT</span>
|
||||
|
||||
<span class="comment"> 1. The && is replaced by ||</span>
|
||||
<span class="comment"> 2. The relational operators are reversed</span>
|
||||
<span class="comment"> 3. There is a ! (NOT) outside the prenthesis</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">if</span> ( ! (number < <span class="number">0</span> || number > <span class="number">10</span>) )
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="literal">\n</span><span class="string">Thank you for entering number </span><span class="string">"</span> + number + <span class="string">"</span><span class="string">!</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span> {
|
||||
System.out.println(<span class="string">"</span><span class="literal">\n</span><span class="string">"</span> + number + <span class="string">"</span><span class="string"> is not between 0 and 10! What's wrong with you man?</span><span class="string">"</span>);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
66
lab7_CalebFontenot/Not2.html
Normal file
66
lab7_CalebFontenot/Not2.html
Normal file
@ -0,0 +1,66 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Not2.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}
|
||||
.ST3 {color: #9876aa; font-family: monospace; font-style: italic}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.ST0 {color: #287bde}
|
||||
.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/Not2.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="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> Not2 {
|
||||
<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">// Create Scanner</span>
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.<span class="ST3">in</span>);
|
||||
|
||||
<span class="comment">// Setup vars</span>
|
||||
<span class="literal">int</span> number;
|
||||
|
||||
<span class="comment">// Prompt for input</span>
|
||||
System.<span class="ST3">out</span>.print(<span class="string">"</span><span class="string">Please enter a number that is divisable by 10 and greater than 100: </span><span class="string">"</span>);
|
||||
number = input.nextInt();
|
||||
|
||||
<span class="comment">// Compute</span>
|
||||
<span class="comment">//if ( number % 10 == 0 && number > 100)</span>
|
||||
<span class="literal">if</span> ( ! (number % <span class="number">10</span> != <span class="number">0</span> || number < <span class="number">100</span>) )
|
||||
{
|
||||
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">Thanks for entering number </span><span class="string">"</span> + number+ <span class="string">"</span><span class="string">!</span><span class="string">"</span>);
|
||||
}
|
||||
<span class="literal">else</span>
|
||||
{
|
||||
System.<span class="ST3">out</span>.println(number + <span class="string">"</span><span class="string"> is not fufilling the request!</span><span class="string">"</span>);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
54
lab7_CalebFontenot/Or1.html
Normal file
54
lab7_CalebFontenot/Or1.html
Normal file
@ -0,0 +1,54 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Or1.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}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.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/Or1.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java 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="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> Or1 {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="string">Please enter a number less than 0 or greater than or equal to 1,000</span><span class="string">"</span>);
|
||||
<span class="literal">int</span> number = <span class="literal">new</span> Scanner(System.in).nextInt();
|
||||
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> The || is the OR operator which ORs 2 operands</span>
|
||||
<span class="comment"> The ORing evaluates to true if either of the operands of the OR is true</span>
|
||||
<span class="comment"> UNDERSTAND THIS OR || please</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">if</span> (number < <span class="number">0</span> || number >= <span class="number">1000</span>)
|
||||
System.out.println(<span class="string">"</span><span class="literal">\n</span><span class="string">Thank you for entering number </span><span class="string">"</span> + number );
|
||||
<span class="literal">else</span>
|
||||
System.out.println(<span class="string">"</span><span class="literal">\n</span> <span class="string">"</span> + number + <span class="string">"</span><span class="string"> is not fulfilling the request!</span><span class="string">"</span>);
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
61
lab7_CalebFontenot/Or2.html
Normal file
61
lab7_CalebFontenot/Or2.html
Normal file
@ -0,0 +1,61 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Or2.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}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.string {color: #6a8759}
|
||||
.number {color: #6897bb}
|
||||
.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/Or2.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java 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="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> Or2 {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
<span class="comment">// Create scanner</span>
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.in);
|
||||
|
||||
<span class="comment">// Define vars</span>
|
||||
<span class="literal">int</span> number;
|
||||
|
||||
<span class="comment">// Prompt for input</span>
|
||||
System.out.print(<span class="string">"</span><span class="string">Please enter a number less than 0 or divisable by 3 or both: </span><span class="string">"</span>);
|
||||
number = input.nextInt();
|
||||
|
||||
<span class="comment">// Compute</span>
|
||||
<span class="literal">if</span> ( number % <span class="number">3</span> == <span class="number">0</span> || number < <span class="number">0</span>)
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="string">Thank you for entering number </span><span class="string">"</span> + number);
|
||||
}
|
||||
<span class="literal">else</span>
|
||||
{
|
||||
System.out.println(number + <span class="string">"</span><span class="string"> is not fufilling the request!</span><span class="string">"</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
70
lab7_CalebFontenot/SubtractionQuiz.html
Normal file
70
lab7_CalebFontenot/SubtractionQuiz.html
Normal file
@ -0,0 +1,70 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>SubtractionQuiz.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}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.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/SubtractionQuiz.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java 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="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> SubtractionQuiz {
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
<span class="comment">// Create scanner outside of loop so we don't create it over and over again</span>
|
||||
Scanner input = <span class="literal">new</span> Scanner(System.in);
|
||||
<span class="literal">while</span>(<span class="literal">true</span>) {
|
||||
<span class="comment">// 1. Generate two random single-digit integers</span>
|
||||
<span class="literal">int</span> number1 = (<span class="literal">int</span>)(Math.random() * <span class="number">10</span>);
|
||||
<span class="literal">int</span> number2 = (<span class="literal">int</span>)(Math.random() * <span class="number">10</span>);
|
||||
|
||||
<span class="comment">// 2. If number < number2, swap number1 with number2</span>
|
||||
<span class="literal">if</span> (number1 < number2)
|
||||
{
|
||||
<span class="literal">int</span> temp = number1;
|
||||
number1 = number2;
|
||||
number2 = temp;
|
||||
}
|
||||
|
||||
<span class="comment">// 3. Prompt the student to answer "what is number1 - number2?"</span>
|
||||
System.out.print(<span class="string">"</span><span class="string">What is </span><span class="string">"</span> + number1 + <span class="string">"</span><span class="string"> - </span><span class="string">"</span> + number2 + <span class="string">"</span><span class="string">? </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> answer = input.nextInt();
|
||||
|
||||
<span class="comment">// 4. Grade the answer and display the result</span>
|
||||
<span class="literal">if</span> (number1 - number2 == answer)
|
||||
System.out.println(<span class="string">"</span><span class="string">You are correct!</span><span class="string">"</span>);
|
||||
<span class="literal">else</span>
|
||||
{
|
||||
System.out.println(<span class="string">"</span><span class="string">Your answer is wrong.</span><span class="string">"</span>);
|
||||
System.out.println(number1 + <span class="string">"</span><span class="string"> - </span><span class="string">"</span> + number2 + <span class="string">"</span><span class="string">should be</span><span class="string">"</span> + (number1 - number2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
BIN
lab7_CalebFontenot/lab7_CalebFontenot.docx
Normal file
BIN
lab7_CalebFontenot/lab7_CalebFontenot.docx
Normal file
Binary file not shown.
BIN
lab7_CalebFontenot/lab7_CalebFontenot.zip
Normal file
BIN
lab7_CalebFontenot/lab7_CalebFontenot.zip
Normal file
Binary file not shown.
@ -4,6 +4,8 @@
|
||||
*/
|
||||
package com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
@ -11,7 +13,17 @@ package com.calebfontenot.lab7_calebfontenot;
|
||||
public class And1 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println("please enter a number between 0 and 10:");
|
||||
System.out.print("please enter a number between 0 and 10: ");
|
||||
int number = new Scanner(System.in).nextInt();
|
||||
|
||||
/*
|
||||
the &&is the AND operator which ANDs 2 operands
|
||||
The ANDing evaluates to true if both of the operands of the AND are true
|
||||
UNDERSTAND THIS AND &&, please
|
||||
*/
|
||||
if ( number >= 0 && number <= 10 )
|
||||
System.out.println("\nthank you for entering number " + number );
|
||||
else
|
||||
System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class And2 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create Scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Setup vars
|
||||
int number;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Please enter a number that is divisable by 10 and greater than 100: ");
|
||||
number = input.nextInt();
|
||||
|
||||
// Compute
|
||||
if ( number % 10 == 0 && number > 100)
|
||||
{
|
||||
System.out.println("Thanks for entering number " + number+ "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(number + " is not fufilling the request!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Bonus {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
//Setup currency formatter
|
||||
NumberFormat defaultFormat = NumberFormat.getCurrencyInstance();
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Setup vars
|
||||
String lastName,
|
||||
firstName;
|
||||
double thisYearsUnits,
|
||||
lastYearsUnits,
|
||||
bonus = 0;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Enter last name: ");
|
||||
lastName = input.nextLine();
|
||||
System.out.print("Enter first name: ");
|
||||
firstName = input.nextLine();
|
||||
System.out.print("Enter this year's units: ");
|
||||
thisYearsUnits = input.nextDouble();
|
||||
System.out.print("Enter last year's units: ");
|
||||
lastYearsUnits = input.nextDouble();
|
||||
|
||||
// Compute!
|
||||
if (thisYearsUnits > lastYearsUnits) {
|
||||
if (1000 > thisYearsUnits) // If thisYearsUnits is less than 1000
|
||||
bonus = 25;
|
||||
else if (thisYearsUnits > 1000 && thisYearsUnits < 3000) // If thisYearsUnits is more than 1000, but less than 3000
|
||||
bonus = 50;
|
||||
else if (thisYearsUnits > 3000 && thisYearsUnits < 6000) // If thisYearsUnits is more than 3000, but less than 6000
|
||||
bonus = 100;
|
||||
else if (thisYearsUnits > 6000) // 6000 and up
|
||||
bonus = 200;
|
||||
}
|
||||
|
||||
// Output
|
||||
System.out.println("Employee Name: ");
|
||||
System.out.println("\t"+ lastName + ", " + firstName);
|
||||
System.out.println("Bonus is "+ defaultFormat.format(bonus));
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Debug1 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int i=1, j=2, k=3;
|
||||
if (i < j && i < k && j < k)
|
||||
{
|
||||
System.out.println("i, j, and k are in increasing order");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
|
||||
*/
|
||||
|
||||
package com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Lab7_CalebFontenot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Not1 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.print("Please enter a number between 0 and 10: ");
|
||||
int number = new Scanner(System.in).nextInt();
|
||||
/*
|
||||
The ! is the NOT operator which reverses a boolean expression.
|
||||
If the expression is true, the not makes it false and vice-versa.
|
||||
|
||||
the || is the OR operator which ORs 2 operands
|
||||
This is the equivalent AND1 by using OR and NOT
|
||||
|
||||
1. The && is replaced by ||
|
||||
2. The relational operators are reversed
|
||||
3. There is a ! (NOT) outside the prenthesis
|
||||
*/
|
||||
if ( ! (number < 0 || number > 10) )
|
||||
{
|
||||
System.out.println("\nThank you for entering number " + number + "!");
|
||||
}
|
||||
else {
|
||||
System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Not2 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create Scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Setup vars
|
||||
int number;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Please enter a number that is divisable by 10 and greater than 100: ");
|
||||
number = input.nextInt();
|
||||
|
||||
// Compute
|
||||
//if ( number % 10 == 0 && number > 100)
|
||||
if ( ! (number % 10 != 0 || number < 100) )
|
||||
{
|
||||
System.out.println("Thanks for entering number " + number+ "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(number + " is not fufilling the request!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Or1 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println("Please enter a number less than 0 or greater than or equal to 1,000");
|
||||
int number = new Scanner(System.in).nextInt();
|
||||
|
||||
/*
|
||||
The || is the OR operator which ORs 2 operands
|
||||
The ORing evaluates to true if either of the operands of the OR is true
|
||||
UNDERSTAND THIS OR || please
|
||||
*/
|
||||
if (number < 0 || number >= 1000)
|
||||
System.out.println("\nThank you for entering number " + number );
|
||||
else
|
||||
System.out.println("\n " + number + " is not fulfilling the request!");
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab7_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Or2 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Define vars
|
||||
int number;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Please enter a number less than 0 or divisable by 3 or both: ");
|
||||
number = input.nextInt();
|
||||
|
||||
// Compute
|
||||
if ( number % 3 == 0 || number < 0)
|
||||
{
|
||||
System.out.println("Thank you for entering number " + number);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(number + " is not fufilling the request!");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user