Question
This is in java language. Please use simple java programming language.
Each of the parts a. through c. below is preceded by a comment indicating what the code do. There is a least one problem with
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code to find the smallest number in an array in java

public class Main
{
   public static void main(String[] args) {
      
        int arr[]={11,2,3,4,5,6,7}; // an array is taken
        int small=arr[0];                // first element in the array is taken as the smallest number
        for(int i=1;i<arr.length;i++) // taking the loop from the second number
        {
            if(arr[i]<small)                //then comparing it with every element
            {
                small=arr[i];                //if an element is found out to be smaller than

                                                       //the small then store in the small by replacing
            }
       
        }
       System.out.println(small);
   }
}

Output: 2

Add a comment
Know the answer?
Add Answer to:
This is in java language. Please use simple java programming language. Each of the parts a....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE...

    PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE PLEASE USE C AS A PROGRAMMING LANGUAGE 11. Initialize a integers in the two-dimensional array testArray to the values 1 through 9 using 1 or more while loops so that the array could be visualized as: 1 2 3 LA 5 6 7 8 9...

  • Please use java language in an easy way and comment as much as you can! Thanks...

    Please use java language in an easy way and comment as much as you can! Thanks (Write a code question) Write a generic method called "findMin" that takes an array of Comparable objects as a parameter. (Use proper syntax, so that no type checking warnings are generated by the compiler.) The method should search the array and return the index of the smallest value.

  • the programming language is in java Problem 2 You are given an array A with n...

    the programming language is in java Problem 2 You are given an array A with n distinct elements. Implement an (n log n)-time algorithm that creates an array B where all elements are in range from 0 to n - 1 and where the order of elements is the same as in A. That is, 0 has the same index in B as the smallest element in A, 1 has the same index in B as the second smallest element...

  • Java programming question: Here is the feedback I received "sort fails. Use Arrays class method to...

    Java programming question: Here is the feedback I received "sort fails. Use Arrays class method to sort." The actual question: Write a program as follows: Declare a five element array of Strings. Use a for loop and keyboard input to populate the array with the names of five friends. Sort the array in alphabetical order. Use a foreach loop to print the sorted array of friends, all on one line. Sample Output (inputs in italics) Enter the names of five...

  • no other details are given, its asking for the invariant programming language: Java Question 3. [15...

    no other details are given, its asking for the invariant programming language: Java Question 3. [15 marks in total Consider the following code fragment with missing statements at ????. Assume that A is a nonempty array of integers and has length N. Assume that it has already been initialised. Refer to this code in parts (a-e) below. A [0] int count 1; int i- 1 while (i< NI1 count> N/2 ) if (xAi]) count++ int x else ???? i+ if...

  • This is java. I need help with my computer science class. Question 11 Assume that you...

    This is java. I need help with my computer science class. Question 11 Assume that you have an array of integers named arr. The following program segment is intended to sum arr [0]through arr[n−1], where n = arr.length:          sum = 0;          i = 0;          n = arr.length;          while (i != n)          {             i++;             sum += arr[i];          } In order for this segment to perform as intended, which of the following modifications, if any, should be made? 1.No modification is necessary...

  • Java is an object-oriented programming language that enables us to define classes and to instantiate them...

    Java is an object-oriented programming language that enables us to define classes and to instantiate them into objects. These objects then call each other’s methods to implement the behavior of the application. The Unified Modeling Language (UML) is an object-oriented visual notation to document the design of object-oriented classes. For this discussion, you will practice designing a Java class called Course, drawing a UML class diagram for the Course class, and then implementing the Course class in Java code. Review...

  • // I need help with the following questions. Please use java programming ECLIPSE language to solve...

    // I need help with the following questions. Please use java programming ECLIPSE language to solve the questions. YOU ONLY NEED TO DIRECTLY COPY IT IN YOUR ECLIPSE APPLICATION AND RUN IT. I NEED THOSE PART WHICH IS SAYS --> "TO BE COMPLETED" I NEED HELP WITH [GET*] AND [REPLACE ALL] AND [ADD INT DOUBLE] PLEASE. import java.util.ArrayList; public class CustomArrayList { //instance variables public int[] data; //data.length gives the capacity public int nItems; //nItems gives items currently in the...

  • Please help me answer these questions in java programming language. Please answer it line after line...

    Please help me answer these questions in java programming language. Please answer it line after line so that I can understand please. Does it compile or not? No programming is done in this exercise, simply answer the questions asked in the code given below. class Exemple { /*Explain why this code does not compile */ public void m1() { foo(); } public int foo() throws Exception { throw new Exception(); } /*Explain why this code is not considered as good...

  • complete in C++ code Lists Many programming languages have some kind list data structure, which allows...

    complete in C++ code Lists Many programming languages have some kind list data structure, which allows for insertion and deletion of elements, essentially an array that changes size. C++ has vectors, Java has the ArrayList, Python has lists (which is what they're called generically anyway). But how do they really work? All of these actually use arrays, which naturally have immutable lengths. Your Task Your task is to write a function, insert, which inserts a new item into an existing...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT