The code you provide doesn't compile as shown, I have fixed what it looks like it should be (and indented it correctly):
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Input the maximum no: of letters upto which u want to speak the word repeatedly:");
int N=sc.nextInt();
String s="Medha";
int x=s.length();
int noofrepetitions=N/x;
int remletters=N%x;
String t="";
for(int i=0; i<noofrepetitions; i++)
{
t+=s;
}
if(remletters>0)
{
t+=s.substring(0, remletters);
}
System.out.println(t);
}
}
If I run that in an online Java IDE (
Online Java Compiler - online editor[
^]) it works fine:
Input the maximum no: of letters upto which u want to speak the word repeatedly:
8
MedhaMed
...Program finished with exit code 0
Press ENTER to exit console.
So ... the problem is something in the environment at your end, and we have no access to that at all (or even any idea what it might be!)