Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
NumberBasedAlphabetsPrint
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; import java.util.Scanner; class Rextester { public static void main(String args[]) { Scanner output=new Scanner(System.in); System.out.println("Enter the Input:"); String input=output.next(); char alphabetes[]=new char[100]; String numbers[]=new String[100]; int j=0,k=0; for(int i=0;i<input.length();i++) { String temp=""; if((input.charAt(i)>='a'&&input.charAt(i)<='z') ||(input.charAt(i)>='A'&&input.charAt(i)<='Z')) { alphabetes[j]=input.charAt(i); j++; } else if((input.charAt(i)>='0'&&input.charAt(i)<='9')) { temp=Character.toString(input.charAt(i)); if(i!=input.length()-1) { if((input.charAt(i+1)>='0'&&input.charAt(i+1)<='9')) { temp=temp+input.charAt(i+1); i++; } } numbers[k]=temp; k++; } } for(int i=0;i<k;i++) { for(int a=0;a<Integer.parseInt(numbers[i]);a++) { System.out.print(alphabetes[i]); } } } } /* Note: 1) Every Wrapper class (Interger,Float,Double,Characther ...) have the following common methods a)Integer.toString(int); Character.toString(char) etc b)Integer.parseInt(String); Float.toString(String) etc */
run
|
edit
|
history
|
help
0
ContainsMethod
Huffman Encoding Tree v2
webPage to string
MinMaxArray
Street light
1.6
Circular array Loop?
1
AllStar
Escaping Literals II