Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Below is a Java Program with the steps in the comments that are in bold. Here is the main directions for the Java program: Write
Below is a Java Program with the steps in the comments that are in bold. Here is the main directions for the Java program: Write an application that inputs five numbers, each of which is between 10 and 100, inclusive. As each number is read, display it only if it is not a duplicate of a number already read. Provide for the worst case, in which all five numbers are different. Use the smallest possible array to solve this problem. Display the complete set of unique values input after the user inputs each new value. Can you help with adding on thank you! import java.util.Scanner; public class Unique { public static void main( String args[]) { Scanner input = new Scanner( System.in ); // 1: create an array of five elements int count = 0; // number of uniques read int entered =0; // number of entered numbers while (entered < numbers.length ) { System.out.print("Enter a number: "); //2: write the code to retrieve the input from user //validate the input //3: write if statement that validates the input [10, 100] if () { // flags where this number already exists boolean containsNumber = false; //increment number of entered numbers entered++; /* 4: Compare the user input to the unique numbers in the array * using a for statement. If the number is unique, continue */ // add input to the array only if the number is not already if (!containsNumber) { // 5: write code to add the number to the array and increment unique items input } // end if else System.out.printf("%d has already been entered ", number); } // end if else System.out.println("Number must be between 10 and 100"); // print the list of unique values 6: Write a for loop to output unique values }// end while } // end class Unique }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started