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

The main method handles all the user input and all the println statements. It as

ID: 3684491 • Letter: T

Question

The main method handles all the user input and all the println statements. It asks the user to enter 3 numbers. The main method should call the two other methods and pass the three numbers to both of them. The main method should print out all the results. The first method is called hasDuplicates and it returns true if any of the numbers are the same, and false otherwise. The second method is called hasAnA and it returns true if the average of the numbers is 90 or more and false otherwise. The main method will also need if statements so that the output looks similar to this….

Enter a number: 80

Enter another number: 85

Enter another number: 80

Some of your numbers are duplicates!

Explanation / Answer

public class Example{

   public static void main(String[] args)
   {
    
      int a;
      int b;
      int c;
      int n=1;
      String s;
      String t;
      do
      {
     if (args.length > 0)
     {
    try {
         System.out. println("Enter a number" );
        a = Integer.parseInt(args[0]);
       b = Integer.parseInt(args[1]);
        c = Integer.parseInt(args[2]);
    } catch (NumberFormatException e) {
        System.err.println("Argument" + args[0] + " must be an integer.");
        System.exit(1);
    }

}
n++;       
      }
       while(n<3);
       s=hasDuplicate(a, b, c);
       if(s=="true")
       {
           System.out.println("Some of your numbers are duplicate!");
       }
       else
       {
           System.out.println("You entered three different numbers!");

       }
       t=hasAnA( a, b, c);
       if(t=="true")
       {
            System.out.println("Averege of the numbers is 90 or more");

       }
       else
       {
            System.out.println("The average of the numbers is below 90");

       }
   }
public static String hasAnA(int a,int b,int c)
   {
       int sum=a+b+c;
       int avg=sum/3;
       if(avg>=90)
       {
           return true;
       }
       else
       {
           return false;
       }
   }
   public static String hasDuplicate(int a,int b,int c)
    {
        if(a=b)
        {
            elseif(a=c)
            {
                else if(b=c)
                {
                    return true;
              
                }
            }
        }
        else
        {
            return false;
        }
    }
}