Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RepeatText {
- public static void main(String[] args){
- if (args.length == 1){
- System.out.println(args[0]);
- return;
- }
- else if (args.length != 2){
- System.out.println("Invalid arguments");
- return;
- }
- try {
- String text = args[0];
- int count = Integer.parseInt(args[1]);
- if (count < 0){
- System.out.println("You have to type positive number!");
- return;
- }
- for (int i = 0; i < count; i++){
- System.out.println(text);
- }
- } catch (Exception ex) {
- System.out.println("You have to type number!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement