lab13
This commit is contained in:
parent
59bf3af574
commit
631aac5163
BIN
lab9_CalebFontenot.zip
Normal file
BIN
lab9_CalebFontenot.zip
Normal file
Binary file not shown.
70
lab9_CalebFontenot/MinimumOf4ConditionalOperator.html
Normal file
70
lab9_CalebFontenot/MinimumOf4ConditionalOperator.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>MinimumOf4ConditionalOperator.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}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/NetBeansProjects/ADSV Java/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4ConditionalOperator.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * To change this license header, choose License Headers in Project Properties.</span>
|
||||
<span class="comment"> * To change this template file, choose Tools | Templates</span>
|
||||
<span class="comment"> * and open the template in the editor.</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.lab9_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">ASDV2</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> MinimumOf4ConditionalOperator {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
Scanner scan = <span class="literal">new</span> Scanner(System.in);
|
||||
<span class="literal">while</span> (<span class="literal">true</span>) {
|
||||
System.out.println(<span class="string">"</span><span class="string">Please enter 4 numbers to find the minimum of the 4: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> _1 = scan.nextInt();
|
||||
<span class="literal">int</span> _2 = scan.nextInt();
|
||||
<span class="literal">int</span> _3 = scan.nextInt();
|
||||
<span class="literal">int</span> _4 = scan.nextInt();
|
||||
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span>
|
||||
+ ((_1 < _4)
|
||||
? (_1 < _3)
|
||||
? (_1 < _2)
|
||||
? _1
|
||||
: _2
|
||||
: (_3 < _2)
|
||||
? _3
|
||||
: _2
|
||||
: (_4 < _3)
|
||||
? (_4 < _2)
|
||||
? _4
|
||||
: _2
|
||||
: (_3 < _2)
|
||||
? _3
|
||||
: _2)
|
||||
);
|
||||
scan.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
63
lab9_CalebFontenot/MinimumOf4DeMorgan.html
Normal file
63
lab9_CalebFontenot/MinimumOf4DeMorgan.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>MinimumOf4DeMorgan.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}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/NetBeansProjects/ADSV Java/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4DeMorgan.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * To change this license header, choose License Headers in Project Properties.</span>
|
||||
<span class="comment"> * To change this template file, choose Tools | Templates</span>
|
||||
<span class="comment"> * and open the template in the editor.</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.lab9_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">ASDV2</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> MinimumOf4DeMorgan {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
Scanner scan = <span class="literal">new</span> Scanner(System.in);
|
||||
<span class="literal">while</span> (<span class="literal">true</span>) {
|
||||
System.out.print(<span class="string">"</span><span class="string">Please enter 4 numbers to find the minimum of the 4: </span><span class="string">"</span>);
|
||||
System.out.println(<span class="string">""</span>);
|
||||
<span class="literal">int</span> _1 = scan.nextInt();
|
||||
<span class="literal">int</span> _2 = scan.nextInt();
|
||||
<span class="literal">int</span> _3 = scan.nextInt();
|
||||
<span class="literal">int</span> _4 = scan.nextInt();
|
||||
|
||||
<span class="literal">if</span> (!(_1 > _4 || _1 > _3 || _1 > _2)) { <span class="comment">// Is 1 the minimum?</span>
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _1);
|
||||
} <span class="literal">else</span> <span class="literal">if</span> (!(_2 > _4 || _2 > _3 || _2 > _1)) { <span class="comment">// Is 2 the minimum?</span>
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _2);
|
||||
} <span class="literal">else</span> <span class="literal">if</span> (!(_3 > _4 || _3 > _2 || _3 > _1)) { <span class="comment">// Is 3 the minimum?</span>
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _3);
|
||||
} <span class="literal">else</span> { <span class="comment">// All other conditions failed, _4 must be the minimum</span>
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _4);
|
||||
}
|
||||
scan.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
84
lab9_CalebFontenot/MinimumOf4NestedIfs.html
Normal file
84
lab9_CalebFontenot/MinimumOf4NestedIfs.html
Normal file
@ -0,0 +1,84 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>MinimumOf4NestedIfs.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}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/NetBeansProjects/ADSV Java/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4NestedIfs.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * To change this license header, choose License Headers in Project Properties.</span>
|
||||
<span class="comment"> * To change this template file, choose Tools | Templates</span>
|
||||
<span class="comment"> * and open the template in the editor.</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.lab9_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">ASDV2</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> MinimumOf4NestedIfs {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
|
||||
Scanner scan = <span class="literal">new</span> Scanner(System.in);
|
||||
<span class="literal">while</span> (<span class="literal">true</span>) {
|
||||
System.out.println(<span class="string">"</span><span class="string">Please enter 4 numbers to find the minimum of the 4: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> _1 = scan.nextInt();
|
||||
<span class="literal">int</span> _2 = scan.nextInt();
|
||||
<span class="literal">int</span> _3 = scan.nextInt();
|
||||
<span class="literal">int</span> _4 = scan.nextInt();
|
||||
|
||||
<span class="literal">if</span> (_1 < _4) {
|
||||
<span class="literal">if</span> (_1 < _3) {
|
||||
<span class="literal">if</span> (_1 < _2) {
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _1);
|
||||
} <span class="literal">else</span> {
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _2);
|
||||
}
|
||||
} <span class="literal">else</span> {
|
||||
<span class="literal">if</span> (_3 < _2) {
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _3);
|
||||
} <span class="literal">else</span> {
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _2);
|
||||
}
|
||||
}
|
||||
} <span class="literal">else</span> {
|
||||
<span class="literal">if</span> (_4 < _3) {
|
||||
<span class="literal">if</span> (_4 < _2) {
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _4);
|
||||
} <span class="literal">else</span> {
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _2);
|
||||
}
|
||||
} <span class="literal">else</span> {
|
||||
<span class="literal">if</span> (_3 < _2) {
|
||||
System.out.println(<span class="string">"</span><span class="string">minumum= </span><span class="string">"</span> + _3);
|
||||
} <span class="literal">else</span> {
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scan.next();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
63
lab9_CalebFontenot/MinimumOf4WithANDs.html
Normal file
63
lab9_CalebFontenot/MinimumOf4WithANDs.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>MinimumOf4WithANDs.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}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/NetBeansProjects/ADSV Java/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4WithANDs.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * To change this license header, choose License Headers in Project Properties.</span>
|
||||
<span class="comment"> * To change this template file, choose Tools | Templates</span>
|
||||
<span class="comment"> * and open the template in the editor.</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.lab9_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">ASDV2</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> MinimumOf4WithANDs {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
||||
{
|
||||
Scanner scan = <span class="literal">new</span> Scanner(System.in);
|
||||
<span class="literal">while</span> (<span class="literal">true</span>) {
|
||||
System.out.print(<span class="string">"</span><span class="string">Please enter 4 numbers to find the minimum of the 4: </span><span class="string">"</span>);
|
||||
<span class="literal">int</span> _1 = scan.nextInt();
|
||||
<span class="literal">int</span> _2 = scan.nextInt();
|
||||
<span class="literal">int</span> _3 = scan.nextInt();
|
||||
<span class="literal">int</span> _4 = scan.nextInt();
|
||||
System.out.println(<span class="string">""</span>);
|
||||
|
||||
<span class="literal">if</span> (_1 <= _4 && _1 <= _3 && _1 <= _2) { <span class="comment">// Is 1 the minimum?</span>
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _1);
|
||||
} <span class="literal">else</span> <span class="literal">if</span> (_2 <= _4 && _2 <= _3 && _2 <= _1) { <span class="comment">// Is 2 the minimum?</span>
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _2);
|
||||
} <span class="literal">else</span> <span class="literal">if</span> (_3 <= _4 && _3 <= _2 && _3 <= _1) { <span class="comment">// Is 3 the minimum?</span>
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _3);
|
||||
} <span class="literal">else</span> { <span class="comment">// All other conditions failed, _4 must be the minimum</span>
|
||||
System.out.println(<span class="string">"</span><span class="string">minimum= </span><span class="string">"</span> + _4);
|
||||
}
|
||||
scan.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
Binary file not shown.
@ -13,17 +13,18 @@ import java.util.Scanner;
|
||||
*/
|
||||
public class MinimumOf4ConditionalOperator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
while (true) {
|
||||
System.out.println("Please enter 4 numbers to find the minimum of the 4: ");
|
||||
int _1 = scan.nextInt();
|
||||
int _2 = scan.nextInt();
|
||||
int _3 = scan.nextInt();
|
||||
int _4 = scan.nextInt();
|
||||
|
||||
System.out.println("minimum= " +
|
||||
((_1 < _4)
|
||||
System.out.println("minimum= "
|
||||
+ ((_1 < _4)
|
||||
? (_1 < _3)
|
||||
? (_1 < _2)
|
||||
? _1
|
||||
@ -39,5 +40,7 @@ public class MinimumOf4ConditionalOperator {
|
||||
? _3
|
||||
: _2)
|
||||
);
|
||||
scan.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,26 +13,27 @@ import java.util.Scanner;
|
||||
*/
|
||||
public class MinimumOf4DeMorgan {
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
System.out.println("Please enter 4 numbers to find the minimum of the 4: ");
|
||||
while (true) {
|
||||
System.out.print("Please enter 4 numbers to find the minimum of the 4: ");
|
||||
System.out.println("");
|
||||
int _1 = scan.nextInt();
|
||||
int _2 = scan.nextInt();
|
||||
int _3 = scan.nextInt();
|
||||
int _4 = scan.nextInt();
|
||||
|
||||
if (! (_1 > _4 || _1 > _3 || _1 > _2)) { // Is 1 the minimum?
|
||||
if (!(_1 > _4 || _1 > _3 || _1 > _2)) { // Is 1 the minimum?
|
||||
System.out.println("minimum= " + _1);
|
||||
}
|
||||
else if (! (_2 > _4 || _2 > _3 || _2 > _1)) { // Is 2 the minimum?
|
||||
} else if (!(_2 > _4 || _2 > _3 || _2 > _1)) { // Is 2 the minimum?
|
||||
System.out.println("minimum= " + _2);
|
||||
}
|
||||
else if (! (_3 > _4 || _3 > _2 || _3 > _1)) { // Is 3 the minimum?
|
||||
} else if (!(_3 > _4 || _3 > _2 || _3 > _1)) { // Is 3 the minimum?
|
||||
System.out.println("minimum= " + _3);
|
||||
}
|
||||
else { // All other conditions failed, _4 must be the minimum
|
||||
} else { // All other conditions failed, _4 must be the minimum
|
||||
System.out.println("minimum= " + _4);
|
||||
}
|
||||
scan.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,42 +13,27 @@ import java.util.Scanner;
|
||||
*/
|
||||
public class MinimumOf4WithANDs {
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner scan = new Scanner(System.in);
|
||||
while (true) {
|
||||
System.out.print("Please enter 4 numbers to find the minimum of the 4: ");
|
||||
int _1 = scan.nextInt();
|
||||
int _2 = scan.nextInt();
|
||||
int _3 = scan.nextInt();
|
||||
int _4 = scan.nextInt();
|
||||
System.out.println("");
|
||||
|
||||
System.out.println("Please enter 4 numbers to find the minimum of the 4: ");
|
||||
int _1 = 4; //scan.nextInt();
|
||||
int _2 = 3; //scan.nextInt();
|
||||
int _3 = 2; //scan.nextInt();
|
||||
int _4 = 1; //scan.nextInt();
|
||||
/*
|
||||
if (_1 < _2) { // Is x less than y?
|
||||
if (_1 < _3) { // Is x less than z?
|
||||
//System.out.println("x is less than z!");
|
||||
if (_1 <= _4 && _1 <= _3 && _1 <= _2) { // Is 1 the minimum?
|
||||
System.out.println("minimum= " + _1);
|
||||
} else {
|
||||
//System.out.println("z is less than x!");
|
||||
System.out.println("minimum= " + _3);
|
||||
}
|
||||
} else if (_2 < _3) { // Is y less than z?
|
||||
//System.out.println("y is less than z!");
|
||||
} else if (_2 <= _4 && _2 <= _3 && _2 <= _1) { // Is 2 the minimum?
|
||||
System.out.println("minimum= " + _2);
|
||||
} else {
|
||||
//System.out.println("z is less than y!");
|
||||
} else if (_3 <= _4 && _3 <= _2 && _3 <= _1) { // Is 3 the minimum?
|
||||
System.out.println("minimum= " + _3);
|
||||
}
|
||||
*/
|
||||
if (_1 < _4 && _1 < _3 && _1 < _2) { // Is 1 the minimum?
|
||||
System.out.println("minimum= " + _1);
|
||||
}
|
||||
else if (_2 < _4 && _2 < _3 && _2 < _1) { // Is 2 the minimum?
|
||||
System.out.println("minimum= " + _2);
|
||||
}
|
||||
else if (_3 < _4 && _3 < _2 && _3 < _1) { // Is 3 the minimum?
|
||||
System.out.println("minimum= " + _3);
|
||||
}
|
||||
else { // All other conditions failed, _4 must be the minimum
|
||||
} else { // All other conditions failed, _4 must be the minimum
|
||||
System.out.println("minimum= " + _4);
|
||||
}
|
||||
scan.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user