Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Exc3CharactersRange {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- char symbol1 = scanner.nextLine().charAt(0);
- char symbol2 = scanner.nextLine().charAt(0);
- printSymbols(symbol1,symbol2);
- }
- private static void printSymbols(char symbol1, char symbol2) {
- if (symbol1 > symbol2){
- char first = symbol1;
- symbol1 = symbol2;
- symbol2 = first;
- }
- for (int i = symbol1 + 1; i <symbol2; i++) {
- System.out.print((char)i + " ");
- }
- }
- }
- //Write a method that receives two characters and prints on a single line
- // all the characters in between them according to ASCII.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement