Assignment, Books, JAVA, PDFs, Programmimg Languages, Tips

[JAVA Assignment] Write a program to allow user to enter 10 Integers and writes the smallest number

Hey Friends, main motive to write this post is to enhance your programming skills by practicing it. As this is one of  my assignment question.It will very helpful you to enhace your programming skills.

In this question you will use Scanner methos to input data from uses, loops and conditional Statements.

Here is the Code-

import java.util.Scanner;

class User1

{

public static void main(String args[])

{

int arr[]=new int[10];

int smallest=32768, temp;

Scanner input=new Scanner(System.in);

System.out.println(“enter 10 integers”);

for(int i=0;i<10;i++)

{

arr[i]=input.nextInt();

}

for(int i=0;i<10;i++)

{

if(arr[i]<smallest)

{

temp=smallest;

smallest=arr[i];

arr[i]=temp;

}

}

System.out.print(“smallest number=”+smallest);

}

}

 

You can download source code with class file from here

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s