new semester, new repo structure
This commit is contained in:
@@ -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>
|
@@ -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>
|
@@ -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>
|
@@ -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.
14
Semester 1/Assignments/lab9_CalebFontenot/pom.xml
Normal file
14
Semester 1/Assignments/lab9_CalebFontenot/pom.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.calebfontenot</groupId>
|
||||
<artifactId>lab9_CalebFontenot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>18</maven.compiler.source>
|
||||
<maven.compiler.target>18</maven.compiler.target>
|
||||
<exec.mainClass>com.calebfontenot.lab9_calebfontenot.Lab9_CalebFontenot</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* 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.lab9_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Lab9_CalebFontenot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.calebfontenot.lab9_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ASDV2
|
||||
*/
|
||||
public class MinimumOf3 {
|
||||
|
||||
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 x = scan.nextInt();
|
||||
int y = scan.nextInt();
|
||||
int z = scan.nextInt();
|
||||
|
||||
/*
|
||||
if ( x < y )
|
||||
if ( x < z )
|
||||
System.out.println("minimum= " + x);
|
||||
else
|
||||
System.out.println("minimum= " + z);
|
||||
else if ( y < z )
|
||||
System.out.println("minimum= " + y);
|
||||
else
|
||||
System.out.println("minimum= " + z);
|
||||
|
||||
*/
|
||||
System.out.println(
|
||||
(x < y)
|
||||
? (x < z) ? "minimum= " + x
|
||||
: "minimum= " + z
|
||||
: (y < z) ? "minimum= " + y : "minimum= " + z
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.calebfontenot.lab9_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ASDV2
|
||||
*/
|
||||
public class MinimumOf4ConditionalOperator {
|
||||
|
||||
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)
|
||||
? (_1 < _3)
|
||||
? (_1 < _2)
|
||||
? _1
|
||||
: _2
|
||||
: (_3 < _2)
|
||||
? _3
|
||||
: _2
|
||||
: (_4 < _3)
|
||||
? (_4 < _2)
|
||||
? _4
|
||||
: _2
|
||||
: (_3 < _2)
|
||||
? _3
|
||||
: _2)
|
||||
);
|
||||
scan.next();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.calebfontenot.lab9_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ASDV2
|
||||
*/
|
||||
public class MinimumOf4DeMorgan {
|
||||
|
||||
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();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.calebfontenot.lab9_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ASDV2
|
||||
*/
|
||||
public class MinimumOf4NestedIfs {
|
||||
|
||||
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();
|
||||
|
||||
if (_1 < _4) {
|
||||
if (_1 < _3) {
|
||||
if (_1 < _2) {
|
||||
System.out.println("minimum= " + _1);
|
||||
} else {
|
||||
System.out.println("minimum= " + _2);
|
||||
}
|
||||
} else {
|
||||
if (_3 < _2) {
|
||||
System.out.println("minimum= " + _3);
|
||||
} else {
|
||||
System.out.println("minimum= " + _2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (_4 < _3) {
|
||||
if (_4 < _2) {
|
||||
System.out.println("minimum= " + _4);
|
||||
} else {
|
||||
System.out.println("minimum= " + _2);
|
||||
}
|
||||
} else {
|
||||
if (_3 < _2) {
|
||||
System.out.println("minumum= " + _3);
|
||||
} else {
|
||||
System.out.println("minimum= " + _2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scan.next();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.calebfontenot.lab9_calebfontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ASDV2
|
||||
*/
|
||||
public class MinimumOf4WithANDs {
|
||||
|
||||
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("");
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user