I\'m having trouble figuring out how to fix these errors I keep getting for my code
import java.util.Scanner;
public class Unit02Prog1 {
public static void
if (numWords >= 50) {
numWords is a string, and >=
only works on numbers.
You have 2 options for fixing this:
Read the number in as a String and convert it to a number
temp = input.nextLine();
numWords = Integer.parseInt(temp);
This way means you can check manually, and do not need to catch an exception if the number is wrong.
Read the number in as a number straight away
numWords = input.nextInt();
This way is less code, but you will need to catch a NumberFormatException
if the input is not an integer.
input.next()
a lot, depending on your inputs you may want to use nextLine
insteadSystem.out.printf
to clean up your printing code