Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. static Scanner myi = new Scanner(System.in);
  2.  
  3. public static void main(String[] args) {
  4. System.out.println("Enter a number, 1 or 2");
  5. int number = myi.nextInt();
  6. if (number == 1) {
  7. ascii();
  8.  
  9. }
  10. if (number == 2) {
  11. number();
  12.  
  13. } else {
  14. System.out.println("error");
  15.  
  16. }
  17. }
  18.  
  19. private static void ascii() {
  20. Scanner myi = new Scanner(System.in);
  21. int name = myi.nextInt();
  22. char c = (char) name;
  23. System.out.println("-----------");
  24. System.out.println(c);
  25.  
  26. }
  27.  
  28. private static void number() {
  29. int ascii = myi.nextInt();
  30. char c = (char) ascii;
  31. System.out.println("-----------");
  32. System.out.println(c);
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement