Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.zazospackage;
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- ArrayList<Integer> numbers = new ArrayList<>();
- int number;
- System.out.println("Welcome to the sorting program, enter the numbers you wish to be sorted.");
- System.out.println("Type -1 to stop entering numbers.");
- do{
- System.out.print("Number: ");
- number = input.nextInt();
- numbers.add(number);
- }while(number != -1);
- Collections.sort(numbers, Collections.reverseOrder());
- for(int i=0; i < numbers.size(); i++){
- if(numbers.get(i) == -1){
- numbers.remove(i);
- }
- else {
- System.out.println(numbers.get(i));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement