Previously I had the while statement as true and swapped the if and else but was getting and infinite loop. I have no idea on how to fix this import java.util.Scanner;