Reverse Order Java

Reverse Order Java

I am trying to get this into reverse order. Does anybody know how

import java.util.*;

public class Smallest {

public static void main(String[] args) {
    Scanner kybd = new Scanner(System.in);
    //create array to hold 10 integers
    int[] numbers = new int[10];

    System.out.println("Enter 10 integers: ");
    //read 10 integers into array
    for (int i = 0; i < numbers.length; i++) {
        numbers[i] = kybd.nextInt();
    }

    //initialise largest value and location to first array element
    int smallest = numbers[0];
    int SmallestLocation = 0;

    //step through each array location
    for (int i = 1; i < numbers.length; i++) {
        //check if arra<y location is new largest
        if (numbers[i] < smallest) {
            smallest = numbers[i];
            SmallestLocation = i;
        }

//output value and location of largest element System.out.println("Smallest value: " + smallest); System.out.println("Location of largest value: " + SmallestLocation);

}

}

}

View Answers

December 7, 2011 at 3:00 PM

import java.util.*;

public class Smallest {

public static void main(String[] args) {
    Scanner kybd = new Scanner(System.in);
    int[] numbers = new int[4];

    System.out.println("Enter 10 integers: ");
    for (int i = 0; i < numbers.length; i++) {
        numbers[i] = kybd.nextInt();
    }

    int smallest = numbers[0];
    int SmallestLocation = 0;

    for (int i = 1; i < numbers.length; i++) {
        if (numbers[i] < smallest) {
            smallest = numbers[i];
            SmallestLocation = i;
        }
    }
System.out.println("Smallest value: " + smallest); 
System.out.println("Location of largest value: " + SmallestLocation);

System.out.println("Numbers in reverse order: ");
for (int i = numbers.length-1; i >=0; i--) {
       System.out.println(numbers[i]);
    }
}

}

December 7, 2011 at 3:01 PM

import java.util.*;

public class Smallest {

public static void main(String[] args) {
    Scanner kybd = new Scanner(System.in);
    int[] numbers = new int[10];

    System.out.println("Enter 10 integers: ");
    for (int i = 0; i < numbers.length; i++) {
        numbers[i] = kybd.nextInt();
    }

    int smallest = numbers[0];
    int SmallestLocation = 0;

    for (int i = 1; i < numbers.length; i++) {
        if (numbers[i] < smallest) {
            smallest = numbers[i];
            SmallestLocation = i;
        }
    }
System.out.println("Smallest value: " + smallest); 
System.out.println("Location of largest value: " + SmallestLocation);

System.out.println("Numbers in reverse order: ");
for (int i = numbers.length-1; i >=0; i--) {
       System.out.println(numbers[i]);
    }
}

}

Ads









Related Tutorials/Questions & Answers:
Reverse Order Java
Reverse Order Java   I am trying to get this into reverse order. Does... in reverse order: "); for (int i = numbers.length-1; i >=0; i...); System.out.println("Numbers in reverse order: "); for (int i = numbers.length-1; i
Reverse word of string in alphabetical order
Reverse word of string in alphabetical order  wap a program that reverse word of string in alphabetical order. e.g. input by user The purpose of education is to replace an empty mind with an open one output
Advertisements
PHP Array Sort in Reverse Order
the PHP Array Sort in Reverse Order. Please suggest any online reference or example... in reverse order. There are rsort(), arsort(), and krsort()functions in PHP. By using these function we sort the values, keys in reverse order in PHP. Find
string reverse order
string reverse order  Hi I have string s= " kalins naik" then how can i print string s=" naik kalins" Thanks kalins naik   import java.util.*; public class ReverseWords{ public static void main(String[] args
Java Read Lines from Text File and Output in Reverse order to a Different Text File
Java Read Lines from Text File and Output in Reverse order to a Different Text... the JButton. Each line in the file then needs to be converted in Reverse Order... by line and output in reverse order to the text area field. Can someone help
in unix which command is used to sort the lines of data in a file in reverse order
in reverse order   " sort -r " command in unix is used to sort the lines of data in a file in reverse order...in unix which command is used to sort the lines of data in a file in reverse
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
A Program To Reverse Words In String in Java .
A Program To Reverse Words In String in Java .  A Program To Reverse Words In String in Java :- For Example :- Input:- Computer Software Output :- Software Computer
String reverse in java
String reverse in java In this section we are going to discuss about how to reverse a sting in java. There are many ways to reverse a string in java  java API provides StringBuffer and StringBuilder  reverse() method which
Reverse
Reverse  How to reverse two digits in javaprogramming
Reverse
Reverse  How to reverse two digits in javaprogramming
String Reverse In Java Example
into its reverse order. In Java we can reverse a number using various ways. We...String Reverse In Java Example In this tutorial we will read about reversing... of characters in reverse order. As well as, we can apply our own logic
Java Reverse integer array
Java Reverse integer array In this tutorial, you will learn how to reverse... array[]=reverse(a); System.out.println("Array In Reverse Order: "...]); } } } Output: Enter five array elements: 3 5 6 2 4 Array In Reverse Order: 4
A Program To Reverse Words In String in Java
A Program To Reverse Words In String in Java  A Program To Reverse Words In String in Java for example: Input:- Computer Software Output... Tell Me This Program.  Here is an example that reverse the words
Java reverse number
Java reverse number In this tutorial, you will learn how to reverse a number in java. In java, you can use arithmetic operators like division operator(/) and remainder operator(%) to reverse the number. The division operator returns
JavaScript array reverse example
will reverse the order of element into the array. This has a simple syntax...; which contains three elements. Now we can reverse the array elements order... JavaScript array reverse example   
Reverse String Program in Java
Reverse String Program in Java We are going to describe about reverse string program in java. In this example reverses a string entered by the user. We... in String Java reverse string without using inbuilt functions
String Reverse in Java
String Reverse in Java       In this example we are going to reverse a given string... the input string by using the StringBuffer(String string) method, reverse
order
order   write a java code to enter order of number of chocolates(bar,powder,giftbox) in arraylist. Also consider exceptional cases like entering integer in name use try,catch ,throw to deal with exception
Java reverse string without using inbuilt functions
Java reverse string without using inbuilt functions In this tutorial, you will learn how to reverse string without using any inbuilt functions. Here, we have created a method to reverse the string and returns a new string with reverse
Alphabetical order - Java Beginners
clicked the view button Now i want to display the files in alphabetical order
reverse string
reverse string  how to reverse a string without changing its place...=input.nextLine(); String reverse = new StringBuffer(str).reverse().toString(); System.out.println("Reverse: " + reverse); } } Thanks
reverse alphabet
reverse alphabet  e d c b a d c b a c b a b a a code for this pattern in c language
String Reverse Using StringUtils
): This method is used to reverse the order of a buffered string. It returns a null... or StringUtils.reverse("") = "" otherwise reverse order will returns e.g.... String Reverse Using StringUtils   
Reverse integer array program
with all the elements in reverse order. For example, if the input array is [2, 4, 6, 8...Reverse integer array program  Been tasked with the following.... I have this so far: public static int [] reverse (int a[]){ for ( int
reverse indexing
reverse indexing  how to list out all the pages names that have keyword common in them when pages names and their respective keywords are given as input in text file format
Java reverse words in a string using only loops
Java reverse words in a string using only loops In this tutorial, you will learn how to reverse words in a string without using any inbuilt methods like...;=c.length;i++) { if(i==c.length) { reverse(c,word_start_index,i-1); } else
String reverse program
String reverse program  write a java program for reverse string? if the string is "Hi welcome to hyderabad" the reverse string is "hyderabad to welcome Hi"   I hope you would have applied your logic before asking

Ads