I began to code this example to output smallest number. import java.
View the step-by-step solution to:

Question

I began to code this example to output smallest number. With input 7, 15, 3


Please review this

code I unsure were my mistakes are.


import java.util.Scanner;


public class LabProgram {

  public static void main(String[] args) {

           

     Scanner scnr = new Scanner(System.in);

           

        int userInteger;

        int smallestNumber;

        

     System.out.print("Enter Input Value: ");

     userInteger = scnr.nextInt();

     

     smallestNumber = userInteger;

     

     if(userInteger != smallestNumber) {

        smallestNumber = userInteger;

        

     }else if(userInteger < smallestNumber) {

     smallestNumber = userInteger;

  }

  System.out.println("Enter Input Value: ");

     userInteger = scnr.nextInt();

     

     System.out.println(userInteger);

  

  if(userInteger != smallestNumber) {

        smallestNumber = userInteger;

        

     }else if(userInteger < smallestNumber) {

     smallestNumber = userInteger;

  }

  

  

  }

  

  

}

Top Answer

The java code can be created using below idea: Get first number from user, assign smallest number to... View the full answer

smallestOutput.PNG

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question