I have the following code and my output is working but I don't know how to use the printf to make this output (66.67%) instead of 66.66666666666667%, just for an example. Any help is appreciated!
public static void evenNumbers(Scanner input)
{
int numNums = 0;
int numEvens = 0;
int sum = 0;
while (input.hasNextInt())
{
int number = input.nextInt();
numNums++;
sum += number;
if (number % 2 == 0)
{
numEvens++;
}
}
System.out.println(numNums + " numbers, sum = " + sum);
System.out.println(numEvens + " evens " + (100.0* numEvens / numNums + "%"));
}
Thank you