file1
file1
file1
A
ABA
import java.util.*; ABCBA
public class monkey ABCDCBA
{ ABCDEDCBA
public static void main(String[] args) ABCDEFEDCBA
{
char i,j;
for(i='A';i<='F';i++)
{
for(char ch='F';ch>=i;ch--)
{
System.out.print(" ");
}
for(j='A';j<=i;j++)
{
System.out.print(j);
}
for(char b=(char)(i-1);b>='A';b--) Output
{ A
System.out.print(b); ABA
} ABCBA
System.out.println("");
ABCDCBA
}
ABCDEDCBA
}
ABCDEFEDCBA
}
2.Write the program to make the following pattern. A
AA
public class ramram ACA
{ ADDA
public static void main(String[] args) AEEEA
{ AFFFFA
char i,j;
for(i='A';i<='F';i++)
{
for(j='A';j<=i;j++)
{
if(j=='A')
{
System.out.print("A");
}
else if(i==j)
{
System.out.print("A");
}
else
{
System.out.print(i);
} Output
} A
System.out.println(""); AA
} ACA
} ADDA
AEEEA
} AFFFFA
3. Write the program to make the following pattern. ******
import java.util.*; * *
public class God { * *
public static void printPattern(int n) * *
{
int i, j; * *
******
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
if (i == 0 || j == 0 || i == n - 1 || j == n - 1) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
System.out.println();
}
}
System.out.println();
}
}
class Main {
Output
Accessing Elements of Array:
First Element: 12
Second Element: 4
Third Element: 5
Fourth Element: 2
Fifth Element: 5
6. Write a program to multiply two 2D array in a single 2D array.
import java.util.*;
import java.util.Scanner;
public class mul {
import java.util.*;
public class oreo {
package soun;
import java.util.*;
public class oreo {
import java.util.*;
public class ramram {
public static void main(String[] args) {
int a;
Scanner sc=new Scanner (System.in);
System.out.println("Enter day no.");
a=sc.nextInt();
switch(a)
{
case 1:
System.out.println("Weekend");
break;
case 2:
System.out.println("Weekday");
break;
case 3:
System.out.println("weekday");
break;
case 4:
System.out.println("Weekday");
break ;
case 5: Output
System.out.println("Weekday"); Sunday
break ; Weekend
case 6:
System.out.println("Weekday");
break ;
case 7:
System.out.println("Weekday");
break ;
default:
System.out.println("Error");
break ;
} }}
12. Write a program to input a string in uppercase and print the
frequency of each character
Example:
INPUT: COMPUTER HARDWARE
package sunshines;
import java.util.Scanner;
public class ey {
output
input: we are in cyber world
output: We Are In Cyber World
16. Write a program to identify that how many alphabet ,numbers and
special number are there in string.
package soun;
import java.util.*;
public class furro {
}
17.Write a program to accept a word and convert it into lowercase if it
is in uppercase,and display the new word by replacing only the vowels
with the character following it.
import java.util.*;
public class ghff
{
public static String convert(String s)
{
StringBuffer str=new StringBuffer(s);
int n=s.length();
char ch;
for(int i=0;i<n;i++)
ch=str.charAt(i);
if( Charater.isUpperCase(ch)==true)
str.setCharAt(i,Charater.toLowerCase(ch));
ch=str.charAt(i);
if(str.charAt(i)=='a'||str.charAt(i)=='e'||str.charAt(i)=='i'||str.charAt(i)=='o'||st
r.charAt(i)=='u')
{
str.setCharAt(i,(char)(ch+1));
}
}
return str.toString();
}
public static void main(String []args)
{
String word;
Scanner kb=new Scanner(System.in);
Input : computer
System.out.println("Enter a word");
Output: cpmpvtfr
word=kb.next();
System.out.println(convert(word));
}
}
18. Write a program to enter the marks and print the grade according
to the entered marks by using if else ladder statement.
public class radhe {
public static void main(String[] args) {
int marks=65;
if(marks<50){
System.out.println("fail");
}
else if(marks>=50 && marks<60){
System.out.println("D grade");
}
else if(marks>=60 && marks<70){
System.out.println("C grade");
}
else if(marks>=70 && marks<80){
System.out.println("B grade");
}
else if(marks>=80 && marks<90){
System.out.println("A grade");
}else if(marks>=90 && marks<100){
System.out.println("A+ grade");
}else{
System.out.println("Invalid!");
}
}
}
Output:
C grade
19. Write a program to find out the entered number is buzz number or
not a buzz number in java
import java.util.Scanner;
class Main {
originalNumber = number;
while (originalNumber != 0)
{
remainder = originalNumber % 10;
result += Math.pow(remainder, 3);
originalNumber /= 10;
}
if(result == number)
System.out.println(number + " is an Armstrong number.");
else
System.out.println(number + " is not an Armstrong number.");
}
}
Output
371 is an Armstrong number