Advertisement
CoineTre

JF-ExcMethods03.CharactersRange

Feb 12th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Exc3CharactersRange {
  4.  
  5.         public static void main(String[] args) {
  6.             Scanner scanner = new Scanner(System.in);
  7.             char symbol1 = scanner.nextLine().charAt(0);
  8.             char symbol2 = scanner.nextLine().charAt(0);
  9.             printSymbols(symbol1,symbol2);
  10.  
  11.         }
  12.  
  13.         private static void printSymbols(char symbol1, char symbol2) {
  14.             if (symbol1 > symbol2){
  15.                 char first = symbol1;
  16.                 symbol1 = symbol2;
  17.                 symbol2 = first;
  18.             }
  19.             for (int i = symbol1 + 1; i <symbol2; i++) {
  20.                 System.out.print((char)i + " ");
  21.             }
  22.         }
  23.     }
  24.  
  25.  
  26. //Write a method that receives two characters and prints on a single line
  27. // all the characters in between them according to ASCII.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement