Saturday, December 7, 2013

Java Program to check whether the words in a string are in ascending order or not.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class AscendingOrder {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));
        System.out.println(" Enter the String ");
        Boolean flag = true;
        String str = reader.readLine();
        for (int index = 0; index <= str.length() - 2; index++) {
            int check = (int) str.charAt(index) - (int) str.charAt(index + 1);
            if (check > 0)
                flag = false;

        }
        if (flag) {
            System.out.println(" Ascending Order");

        } else {
            System.out.println(" Not in Ascending Order");

        }

    }

}

1 comment:

  1. Pragmatic Play launches live casino slot machine - JamBase
    Pragmatic 춘천 출장안마 Play, a 경상북도 출장샵 leading 강릉 출장안마 content 제천 출장안마 provider to the gaming industry, today launched its latest live casino game in the UK with 서울특별 출장안마 the launch of its

    ReplyDelete