Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an application that inputs five numbers, each between 10 and 100, inclusiv

ID: 3745287 • Letter: W

Question

Write an application that inputs five numbers, each between 10 and 100, inclusive. As each number is read, display it only if it’s 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 enters each new value.

Use SIMPLE JAVA code only, Do NOT use advanced code, use beginner level java code. Please do not answer from other chegg posts or sources.

Explanation / Answer

import java.util.Scanner;
public class Myprogram
{
   public static void main(String[] arg)
    {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[4];
        for(int i = 0; i <= 5; i++)
        {
            System.out.println("ENTER THE NUMBER");
            a[i] = sc.nextInt();
            if (i==0)
            {
                System.out.print(a[i]);
            }
            while(i>0)
            {
                for(int j=0; j<=i; j++)
                {
                   if(a[i]==a[j])
                   {
                    break;
                   }
                }
                i--;
            }
         System.out.println(a[i]);
        }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote