This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2022-09-21 20:40:27 -05:00
parent 59bf3af574
commit 631aac5163
9 changed files with 343 additions and 74 deletions

BIN
lab9_CalebFontenot.zip Normal file

Binary file not shown.

View 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">&quot;</span><span class="string">Please enter 4 numbers to find the minimum of the 4: </span><span class="string">&quot;</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">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span>
+ ((_1 &lt; _4)
? (_1 &lt; _3)
? (_1 &lt; _2)
? _1
: _2
: (_3 &lt; _2)
? _3
: _2
: (_4 &lt; _3)
? (_4 &lt; _2)
? _4
: _2
: (_3 &lt; _2)
? _3
: _2)
);
scan.next();
}
}
}
</pre></body>
</html>

View 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">&quot;</span><span class="string">Please enter 4 numbers to find the minimum of the 4: </span><span class="string">&quot;</span>);
System.out.println(<span class="string">&quot;&quot;</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 &gt; _4 || _1 &gt; _3 || _1 &gt; _2)) { <span class="comment">// Is 1 the minimum?</span>
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _1);
} <span class="literal">else</span> <span class="literal">if</span> (!(_2 &gt; _4 || _2 &gt; _3 || _2 &gt; _1)) { <span class="comment">// Is 2 the minimum?</span>
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _2);
} <span class="literal">else</span> <span class="literal">if</span> (!(_3 &gt; _4 || _3 &gt; _2 || _3 &gt; _1)) { <span class="comment">// Is 3 the minimum?</span>
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</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">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _4);
}
scan.next();
}
}
}
</pre></body>
</html>

View 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">&quot;</span><span class="string">Please enter 4 numbers to find the minimum of the 4: </span><span class="string">&quot;</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 &lt; _4) {
<span class="literal">if</span> (_1 &lt; _3) {
<span class="literal">if</span> (_1 &lt; _2) {
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _1);
} <span class="literal">else</span> {
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _2);
}
} <span class="literal">else</span> {
<span class="literal">if</span> (_3 &lt; _2) {
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _3);
} <span class="literal">else</span> {
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _2);
}
}
} <span class="literal">else</span> {
<span class="literal">if</span> (_4 &lt; _3) {
<span class="literal">if</span> (_4 &lt; _2) {
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _4);
} <span class="literal">else</span> {
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _2);
}
} <span class="literal">else</span> {
<span class="literal">if</span> (_3 &lt; _2) {
System.out.println(<span class="string">&quot;</span><span class="string">minumum= </span><span class="string">&quot;</span> + _3);
} <span class="literal">else</span> {
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _2);
}
}
}
scan.next();
}
}
}
</pre></body>
</html>

View 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">&quot;</span><span class="string">Please enter 4 numbers to find the minimum of the 4: </span><span class="string">&quot;</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">&quot;&quot;</span>);
<span class="literal">if</span> (_1 &lt;= _4 &amp;&amp; _1 &lt;= _3 &amp;&amp; _1 &lt;= _2) { <span class="comment">// Is 1 the minimum?</span>
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _1);
} <span class="literal">else</span> <span class="literal">if</span> (_2 &lt;= _4 &amp;&amp; _2 &lt;= _3 &amp;&amp; _2 &lt;= _1) { <span class="comment">// Is 2 the minimum?</span>
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _2);
} <span class="literal">else</span> <span class="literal">if</span> (_3 &lt;= _4 &amp;&amp; _3 &lt;= _2 &amp;&amp; _3 &lt;= _1) { <span class="comment">// Is 3 the minimum?</span>
System.out.println(<span class="string">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</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">&quot;</span><span class="string">minimum= </span><span class="string">&quot;</span> + _4);
}
scan.next();
}
}
}
</pre></body>
</html>

View File

@ -13,31 +13,34 @@ 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("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)
? (_1 < _3)
? (_1 < _2)
? _1
: _2
: (_3 < _2)
? _3
: _2
: (_4 < _3)
? (_4 < _2)
? _4
: _2
: (_3 < _2)
? _3
: _2)
);
System.out.println("minimum= "
+ ((_1 < _4)
? (_1 < _3)
? (_1 < _2)
? _1
: _2
: (_3 < _2)
? _3
: _2
: (_4 < _3)
? (_4 < _2)
? _4
: _2
: (_3 < _2)
? _3
: _2)
);
scan.next();
}
}
}

View File

@ -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);
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();
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();
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
System.out.println("minimum= " + _4);
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
System.out.println("minimum= " + _4);
}
scan.next();
}
}
}

View File

@ -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);
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!");
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("");
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!");
} 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
System.out.println("minimum= " + _4);
}
} else if (_2 < _3) { // Is y less than z?
//System.out.println("y is less than z!");
System.out.println("minimum= " + _2);
} else {
//System.out.println("z is less than y!");
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
System.out.println("minimum= " + _4);
scan.next();
}
}
}