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

can someone help me Write a method named smallestLargest that asks the user to e

ID: 3654048 • Letter: C

Question

can someone help me Write a method named smallestLargest that asks the user to enter numbers, then prints the smallest and largest of all the numbers typed in by the user. You may assume the user enters a valid number greater than 0 for the number of numbers to read. with my code. Here is an example dialogue: How many numbers do you want to enter? 4 Number 1: 5 Number 2: 11 Number 3: -2 Number 4: 3 Smallest = -2 Largest = 11 package examinenumbers; import java.util.Scanner; public class Examinenumbers { public static void main(String[] args) { int min = value; int max = value; Scanner console = new Scanner (System.in); System.out.print(" How many numbers do you have?"); int totalnumber = console.nextInt(); double sum = 0.0; for( int i = 1; i <= totalnumber; i++ ) { System.out.print(" #" + i + " ? "); double next = console.nextDouble(); sum+= next; } for( int i =1; i<= length -1; i++) { if ( value % 2 == 0) { value = value /2; } else { value = 3*value + 1; } if(value> max) { max = value; } else if ( value < min) { min = value; } } System.out.print( " max" + max); System.out.print ( " min " + min); } }

Explanation / Answer

Please rate...

Program Examinenumbers.java

====================================================

import java.util.Scanner;
public class Examinenumbers
{
    public static void main(String[] args)
    {
        int min;
        int max;
        Scanner console = new Scanner (System.in);
        System.out.print(" How many numbers do you have?");
        int totalnumber = console.nextInt();
        int i=1;
        System.out.print(" #" + i + " ? ");
        int a=console.nextInt();
        min=a;max=a;
        for( i = 2; i <= totalnumber; i++ )
        {
            System.out.print(" #" + i + " ? ");
            a = console.nextInt();
            if(a<min)min=a;
            if(a>max)max=a;
        }
        System.out.println("Min: "+min);
        System.out.println("Max: "+max);
    }
}

===================================================

Sample output:

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