Advertisement
Krassi_Daskalova

NestedLoops_ReverseString_Coding

Mar 7th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Coding {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String input = scanner.nextLine();
  8. String reverse = new StringBuffer(input).reverse().toString();
  9.  
  10. for (int i = 0; i <= reverse.length() - 1; i++) {
  11. char currentDig = reverse.charAt(i);
  12. int currentDigToNum = Integer.parseInt("" + currentDig);
  13.  
  14. if (currentDigToNum == 0) {
  15. System.out.println("ZERO");
  16. continue;
  17. }
  18. for (int n = 1; n <= currentDigToNum; n++) {
  19. System.out.print((char) (currentDigToNum + 33));
  20. }
  21. System.out.println();
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement