I was bored this morning, so I decided to make a program where the user can convert either speed, mass, temperature, or length. I used a Scanner and a switch operator to do this. Pretty much, I have the user type in what they want to convert, and then the switch operator runs a certain method based on the answer. I so far only have Mass done, which is why the other methods are commented out. Code and output is below:

Code:

```
import java.util.Scanner;

public class Convertions {
public static void main(String[] args) {
    System.out.println("Would you like to convert: Mass, Temperature,\nLength, or Speed?");
    Scanner scan = new Scanner(System.in);
    String answer = scan.nextLine().toUpperCase();
    scan.close();
    switch(answer) {
        case "MASS":
            massConvert();
            break;
        case "TEMPERATURE":
            //tempConvert();
            break;
        case "LENGTH":
            //lengthConvert();
            break;
        case "SPEED":
            //speedConvert();
            break;
        default:
            System.out.println("Please enter something else!");
    }

}

public static double massConvert() {
    Scanner scanMass = new Scanner(System.in);
    System.out.println("1. kg to lbs\n2. lbs to kg");
    int answerMass = scanMass.nextInt();
    switch(answerMass) {
        case 1:
            System.out.println("Enter a value in kgs:");
            int kiloMass1 = scanMass.nextInt();
            scanMass.close();
            int poundMass1 = (int)((int)kiloMass1 * 2.2046);
            System.out.println(kiloMass1 + " kgs is equal to " + poundMass1 + " lbs");
            break;
        case 2:
            System.out.println("Enter a value in lbs:");
            int poundMass2 = scanMass.nextInt();
            scanMass.close();
            int kiloMass2 = (int)((int)poundMass2/2.2046);
            System.out.println(poundMass2 + " lbs is equal to " + kiloMass2 + " kgs");
            break;
    }
    return 0.0;
}
}

```

Output:

```
Would you like to convert: Mass, Temperature, 
Length, or Speed?
/*This wasn't in the output, but I just want to mention that the line with "Mass" was my input.*/
Mass
1. kg to lbs
2. lbs to kg
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at Convertions.main(Convertions.java:14)

```