public class Swastik {
public static void main(String...args){
int n=9;
int mid=(n+1)/2;
for(int i=1 ; i<=n ; i++) {
for(int j=1 ; j<=n ; j++) {
if( j==mid i==mid (i==1 && j>mid) (i<= mid && j==1) (i == n && j<=mid) || (i>= mid && j==n))
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
public static void main(String...args){
int n=9;
int mid=(n+1)/2;
for(int i=1 ; i<=n ; i++) {
for(int j=1 ; j<=n ; j++) {
if( j==mid
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
import java.util.Scanner;
public class kShapeAlphabets1 {
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
int i, j, alphabet;
System.out.print("Enter K Shape Alphabets Pattern Rows = ");
int rows = sc.nextInt();
System.out.println("Printing K Shape Alphabets Pattern");
for (i = rows - 1; i >= 0; i-- )
{
alphabet = 65;
for (j = 0 ; j <= i; j++ )
{
System.out.print((char)(alphabet + j) + " ");
}
System.out.println();
}
for (i = 1 ; i < rows; i++ )
{
alphabet = 65;
for (j = 0 ; j <= i; j++ )
{
System.out.print((char)(alphabet + j) + " ");
}
System.out.println();
}
}
}
public class kShapeAlphabets1 {
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
int i, j, alphabet;
System.out.print("Enter K Shape Alphabets Pattern Rows = ");
int rows = sc.nextInt();
System.out.println("Printing K Shape Alphabets Pattern");
for (i = rows - 1; i >= 0; i-- )
{
alphabet = 65;
for (j = 0 ; j <= i; j++ )
{
System.out.print((char)(alphabet + j) + " ");
}
System.out.println();
}
for (i = 1 ; i < rows; i++ )
{
alphabet = 65;
for (j = 0 ; j <= i; j++ )
{
System.out.print((char)(alphabet + j) + " ");
}
System.out.println();
}
}
}
public class StringImmutable {
public static void main(String[] args) {
String str1 = "Hello";
String str2 = "World";
// Concatenating two strings
String str3 = str1.concat(str2);
// printing the result
System.out.println("String after concatenation = " + str3);
// changing the original strings
str1 = str1.concat("123");
str2 = str2.concat("456");
// printing the modified strings
System.out.println("String1 after modification = " + str1);
System.out.println("String2 after modification = " + str2);
// printing the final result
System.out.println("Final String after concatenation = " + str3);
}
}
public static void main(String[] args) {
String str1 = "Hello";
String str2 = "World";
// Concatenating two strings
String str3 = str1.concat(str2);
// printing the result
System.out.println("String after concatenation = " + str3);
// changing the original strings
str1 = str1.concat("123");
str2 = str2.concat("456");
// printing the modified strings
System.out.println("String1 after modification = " + str1);
System.out.println("String2 after modification = " + str2);
// printing the final result
System.out.println("Final String after concatenation = " + str3);
}
}
import java.io.*;
public class CountChar
{
public static void main(String[] args) throws IOException
{
String ch;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the Statement:");
ch=br.readLine();
int count=0,len=0;
do
{
try
{
char name[]=ch.toCharArray();
len=name.length;
count=0;
for(int j=0;j<len;j++)
{
if((name[0]==name[j])&&((name[0]>=65&&name[0]<=91)(name[0]>=97&&name[0]<=123) (name[0]>=48&&name[0]<=57)))
count++;
}
if(count!=0)
System.out.println(name[0]+" "+count+" Times");
ch=ch.replace(""+name[0],"");
}
catch(Exception ex){}
}
while(len!=1);
}
public class CountChar
{
public static void main(String[] args) throws IOException
{
String ch;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the Statement:");
ch=br.readLine();
int count=0,len=0;
do
{
try
{
char name[]=ch.toCharArray();
len=name.length;
count=0;
for(int j=0;j<len;j++)
{
if((name[0]==name[j])&&((name[0]>=65&&name[0]<=91)
count++;
}
if(count!=0)
System.out.println(name[0]+" "+count+" Times");
ch=ch.replace(""+name[0],"");
}
catch(Exception ex){}
}
while(len!=1);
}
👍1
public class ReverseWordsInSentence {
public static void main(String[] args) {
String sentence = "which is the biggest continent";
String[] words = sentence.split(" ");
String reversedSentence = "";
for (int i = 0; i < words.length; i++) {
String word = words[i];
String reversedWord = "";
for (int j = word.length() - 1; j >= 0; j--) {
reversedWord = reversedWord + word.charAt(j);
}
reversedSentence = reversedSentence + reversedWord + " ";
}
System.out.println(reversedSentence);
}
}
public static void main(String[] args) {
String sentence = "which is the biggest continent";
String[] words = sentence.split(" ");
String reversedSentence = "";
for (int i = 0; i < words.length; i++) {
String word = words[i];
String reversedWord = "";
for (int j = word.length() - 1; j >= 0; j--) {
reversedWord = reversedWord + word.charAt(j);
}
reversedSentence = reversedSentence + reversedWord + " ";
}
System.out.println(reversedSentence);
}
}
Java Hyd Team
public class ReverseWordsInSentence { public static void main(String[] args) { String sentence = "which is the biggest continent"; String[] words = sentence.split(" "); String reversedSentence = ""; for (int i = 0; i < words.length;…
a java program to reverse each word of sentence
Input: which is the biggest continent
Output: hcihw si eht tseggib tnenitnoc
Input: which is the biggest continent
Output: hcihw si eht tseggib tnenitnoc