Question: I need a little help with my java coding. I need to check that the user actually entered 5 to 10 NUMBERS and no letters.

I need a little help with my java coding. I need to check that the user actually entered 5 to 10 NUMBERS and no letters. Also a way with methods how to get the print out of the average to be in two decimal places. Thank you!!

package averagewithmethods; import java.util.Scanner;

public class AverageWithMethods { public static void main(String[] args) { String numbers = getInput(); double average = calculateAverage(numbers); printResult(numbers, average); } public static String getInput() { Scanner sc = new Scanner(System.in); System.out.println("Enter 5 to 10 numbers: "); String numbers = sc.nextLine(); return numbers; } public static double calculateAverage(String numbers){ String nums[] = numbers.split(" "); double d[] = new double[nums.length]; for(int i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!