Question

IN JAVA... Write a program that would create a one-dimensional array of length 7, with user-specified...

IN JAVA... Write a program that would create a one-dimensional array of length 7, with user-specified values and display the array values. Then search the array for the smallest value and display both the value and its position in the array.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

public class Ideone
{
   public static void main (String[] args)
   {
       Scanner sc=new Scanner(System.in);
       int i,min,index=0;
       int [] arr=new int[7];
       System.out.println("Enter the array elements : ");
       for(i=0;i<7;i++)
       arr[i]=sc.nextInt();
       min=arr[0];
       System.out.print("Values of the array : ");
       for(i=0;i<7;i++)
       System.out.print(arr[i]+" ");
       for(i=0;i<7;i++)
       {
           if(min>arr[i])
           {
           min=arr[i];
           index=i;
           }
       }
       System.out.println("\nsmallest value of the array "+min);
       System.out.println("index of the smallest value : "+index);
   }
}

OUTPUT:-

Success #stdin #stdout 0.145 37620KB Enter the array elements : 45 67 43 21 89 75 87 Values of the array : 45 67 43 21 89 75

// If any doubt please comment

Add a comment
Know the answer?
Add Answer to:
IN JAVA... Write a program that would create a one-dimensional array of length 7, with user-specified...
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
  • Write a java program that specifies three parallel one dimensional arrays name length, width, and area....

    Write a java program that specifies three parallel one dimensional arrays name length, width, and area. Each array should be capable of holding a number elements provided by user input. Using a for loop input values for length and width arrays. The entries in the area arrays should be the corresponding values in the length and width arrays (thus, area[i] =   length [i]* width [i]) after data has been entered display the following output: (in Java)

  • Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values,...

    Q1. Write a program in Java         a. Create 2 separate arrays, of user defined values, of same size         b. Add these 2 arrays. ........................................................................................................................... Q2. Write a program in java (using loop) input any10 numbers from user and store in an array. Check whether each of array element is positive, negative, zero, odd or even number. ............................................................................................................................ Q3. Write a program in Java to display first 10 natural numbers. Find the sum of only odd numbers. .............................................................................................................................. Q4....

  • In Java 2. Array Exercise ( 10 points) Write a Java program that will prompt the...

    In Java 2. Array Exercise ( 10 points) Write a Java program that will prompt the user to input a size of an array. Create an array of type int. Ask a user to fill the array. Create a functions sortArray() and mostFrequency(). The sortArray() function will sort number into incrementing order. The sorting function must be implemented from scratch and it must not use any function from the library. Feel free to use any sorting algorithm. The program will...

  • java Create a program that utilized a multi-dimensional array for the user to input the name...

    java Create a program that utilized a multi-dimensional array for the user to input the name of a team and their number of wins. The user should be able to input up to 10 teams and the wins for each team.

  • Java Programming Use a one-dimensional array to solve the following program. Write an application that inputs...

    Java Programming Use a one-dimensional array to solve the following program. Write an application that inputs six numbers [Keep the numbers in an array]. The numbers must be between 20 and 200, inclusive. If the number is not between 20 and 200, ask for another input. When a number is entered, display the number only if it is not a duplicate of a number already entered. If it is a duplicate of a number already entered, display a message that...

  • Write a java program that create a 2 dimensional array of type double of size 10...

    Write a java program that create a 2 dimensional array of type double of size 10 by 10. Fill the array with random numbers using a random number generator. Print the array contents. Write a java program that creates a file called data.txt that uses the PrintWriter class. Write the numbers 1 to 42 into the file. Close the file. Attach both files. Thank you in advance

  • Write a Java program that will create a random list (array) randomize a  search item to be...

    Write a Java program that will create a random list (array) randomize a  search item to be found in the list sequentially search the array for that item. You must code the search and not use a search function. Display each comparison in the array; the element contents and the index. display whether the item was found or not. Now take that code and alter it to have two lists. Both lists randomize between 1 and 50. While traversing one list,...

  • Please write a Java program that does the following: Create an array of 100 integers. Store...

    Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...

  • Write a console application in c# that uses a one dimensional array; prompt the user to...

    Write a console application in c# that uses a one dimensional array; prompt the user to enter letters, ( a, b, c, … z). As each letter is input, store it in the array only if it is not a duplicate of previous letters entered. After 7 unique letters have been entered, display the unique values in the array. Be sure to test with duplicate values.

  • Write a JAVA program to sort a given array of integers (1 Dimensional) in ascending order...

    Write a JAVA program to sort a given array of integers (1 Dimensional) in ascending order (from smallest to largest). You can either get the array as input or hardcode it inside your program.

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
ADVERTISEMENT