Computer Applications
Write a program to accept a word and print the Symbolic of the accepted word.
Symbolic word is formed by extracting the characters from the first consonant, then add characters before the first consonant of the accepted word and end with "TR".
Example:
AIRWAYS Symbolic word is RWAYSAITR
BEAUTY Symbolic word is BEAUTYTR
Answer
import java.util.Scanner;
class SymbolicWord
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String w, res;
int i, pos = -1;
System.out.print("Enter a word: ");
w = sc.nextLine();
int l = w.length();
for(i = 0; i < l; i++)
{
char ch = Character.toUpperCase(w.charAt(i));
if(!(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'))
{
pos = i;
break;
}
}
if(pos != -1)
res = w.substring(pos) + w.substring(0, pos) + "TR";
else
res = w + "TR";
System.out.println("Symbolic word: " + res);
}
}Output
Related Questions
Write a program to accept the designations of 100 employees in a single dimensional array. Accept the designation from the user and print the total number of employees with the designation given by the user as input.
Example:
Trainee Manager Chef Manager Director Manager Input: Manager Output: 3
Write a program to accept a two-dimensional integer array of order 4 x 5 as input from the user. Check if it is a Sparse Matrix or not. A matrix is considered to be a sparse, if the total number of zero elements is greater than the total number of non-zero elements. Print appropriate messages.
Example:
4 3 0 1 0 1 0 0 2 0 1 0 1 0 0 0 3 2 0 0 Number of zero elements = 11
Number of non zero elements = 9
Matrix is a Sparse MatrixWrite a program to accept a number and check if it is a Mark number or not. A number is said to be Mark when sum of the squares of each digit is an even number as well as the last digit of the sum and the last digit of the number given is same.
Example: n = 246
sum = 2 x 2 + 4 x 4 + 6 x 6 = 56
56 is an even number as well as last digit is 6 for both sum as well as the number.