lab9 misery

master
Chloe Fontenot 🏳️‍⚧️ 2022-09-20 17:03:45 +07:00
parent 121f8ed3e1
commit 5f825c63f7
2 changed files with 91 additions and 0 deletions

@ -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);
System.out.println("Please neter 3 numbers to find the minimum of the 3:");
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);
}
}
}

@ -0,0 +1,52 @@
/*
* 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);
System.out.println("Please neter 3 numbers to find the minimum of the 3:");
int _1 = 1; //scan.nextInt();
int _2 = 2; //scan.nextInt();
int _3 = 3; //scan.nextInt();
int _4 = 4; //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!");
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!");
System.out.println("minimum= " + _2);
} else {
System.out.println("z is less than y!");
System.out.println("minimum= " + _3);
}
/*
if (_1 < _4) {
//if ( ) {
} else {
System.out.println("w is less than y!");
System.out.println("minimum= " + _4);
}
*/
}
}