Use of primitives, wrapper class object

import java.util.Scanner;


public class ScanPrimitives {
    public static void main(String[] args) {    
        Scanner input;

        // enter number
        input = new Scanner(System.in);
        System.out.print("Enter an integer: ");
        try {
            int sampleInputInt = input.nextInt();
            System.out.println(sampleInputInt);
        } catch (Exception e) { 
            System.out.println("Not an integer (form like 159), " + e);
        }
        input.close();

        //enter a number that can contain decimals
        input = new Scanner(System.in);
        System.out.print("Enter a double: ");
        try {
            double sampleInputDouble = input.nextDouble();
            System.out.println(sampleInputDouble);
        } catch (Exception e) {
            System.out.println("Not an double (form like 9.99), " + e);
        }
        input.close();

        
        // enter a true or false
        input =  new Scanner(System.in);
        System.out.print("Enter a boolean: ");
        boolean firstInputBoolean = input.nextBoolean();
        System.out.println(firstInputBoolean);
        System.out.print("Enter 2nd boolean: ");
        boolean secondInputBoolean = input.nextBoolean();
        System.out.println(secondInputBoolean);
        try {
            if (firstInputBoolean != secondInputBoolean) { // one input was true and one was false
                System.out.print("The Or gate is true, as the inputted booleans are different.");
            }
            else { // the inputs were the same
                System.out.print("The Or gate is false, as the inputted booleans are the same.");
            }

        } catch (Exception e) {
            System.out.println("Not an boolean (needs to be true or false), " + e);
        }
        input.close();

        System.out.println("");
        
        // enter a string (basically anything)
        input =  new Scanner(System.in);
        System.out.print("Enter a String: ");
        try {
            String sampleInputString = input.nextLine();
            System.out.println(sampleInputString);
        } catch (Exception e) {
            System.out.println("Not an String, " + e);
        }
        input.close();
    }
}
ScanPrimitives.main(null);
Enter an integer: 5
Enter a double: 5.0
Enter a boolean: true
Enter 2nd boolean: true
The Or gate is false, as the inputted booleans are the same.
Enter a String: p

code.org

int divided = 5 / 2;
double doubleDivided = 5.0 / 2;

System.out.println("When the integer was divided, instead of 2.5 like the double, the answer turns out to be 2, so it seems like the calculation was truncated.");
System.out.println("Integer 5 / 2 is " + divided);
System.out.println("Double 5 / 2 is " + doubleDivided);
When the integer was divided, instead of 2.5 like the double, the answer turns out to be 2, so it seems like the calculation was truncated.
Integer 5 / 2 is 2
Double 5 / 2 is 2.5

compounds assignment

import java.util.Scanner;

public class main {
    public static void main(String[] args){
    Scanner input;
    input = new Scanner(System.in);
    System.out.print("Enter 1st string: ");
    String firstInputString = input.nextLine();
    System.out.println(firstInputString);
    System.out.print("Enter 2nd string: ");
    String secondInputString = input.nextLine();
    System.out.println(secondInputString);
    try {
        firstInputString += secondInputString;
        System.out.println("The strings combined are: " + firstInputString + ".");
    }
    catch (Exception e) {
        System.out.println("Enter a string" + e);
    }
    }
}
main.main(null);
Enter 1st string: hi 
Enter 2nd string: bye
The strings combined are: hi bye.

Pounds to Kilograms

import java.util.Scanner;

public class main {
    public static void main(String[] args){
    Scanner input;
    input = new Scanner(System.in);
    System.out.println("Enter a number of pounds: ");
    try {
        double inputPounds  = input.nextDouble();
        var outputPounds = inputPounds;
        outputPounds = outputPounds * 0.453592;
        System.out.println(inputPounds + " pounds is " + outputPounds + " kg.");
    }
    catch (Exception e) {
        System.out.println("Enter a number" + e);
    }
    }
}
main.main(null);
Enter a number of pounds: 
5.0 pounds is 2.26796 kg.