Untitled
Untitled
Untitled
**
***
****
*****
****
***
**
solution
import java.util.Scanner;
int rows=sc.nextInt();
System.out.print(" ");
}
System.out.print("* ");
System.out.println();
System.out.print(" ");
System.out.print("* ");
System.out.println();
EFFICIENT WAY
import java.util.Scanner;
int rows=sc.nextInt();
int space=rows/2;
int star=1;
System.out.print(" ");
System.out.print("*");
System.out.println();
if(i<=rows/2)
space--;
star=star+2;
}else
space++;
star=star-2;
String Programs
-----------------------------------------------------------------
import java.util.Scanner;
String s=sc.nextLine();
String nstr="";
nstr=nstr+(char)(ch[i]+32);
else
nstr=nstr+ch[i];
System.out.println(nstr);
output -- iamagoodboy
import java.util.Scanner;
String s=sc.nextLine();
String nstr="";
char[] ch=s.toCharArray();
//convert the string into array
for(int i=0;i<ch.length;i++)
if(ch[i]!=' ')
nstr=nstr + ch[i];
System.out.println(nstr);
import java.util.Scanner;
String str=sc.nextLine();
char[] ch=str.toCharArray();
for(int i=0;i<ch.length-1;i++)
for(int j=i+1;j<ch.length;j++)
{
if(ch[i]>ch[j])
char temp=ch[i];
ch[i]=ch[j];
ch[j]=temp;
System.out.println(st);
input RACE
ouput ACER