P2Cart Logo
You have entered a line that ends with a space and terminates with a full stop (.).

Here is the Java program that reads a string input (terminated by a full stop) and displays all the tokens (words) from the string using the Scanner class:

Read more
You have entered a line that ends with a space and terminates with a full stop (.). The special character full stop (.) acts as a terminator to display all the tokens present in the string. Write a program to display all the tokens present in the string by using the scanner class.
Sample Input    : Understanding Computer Applications with BlueJ
   Sample Output : Understanding
                                Computer
                                Applications
                                With
                                BlueJ

Read Answer
Write a program to create a Double Dimensional Array (DDA) as: Char ch=[ ] = new ch[3][3];

This program creates a 3x3 Double Dimensional Array of characters and displays the characters located on the left diagonal, where the row and column indices are equal.

Read more
Write a program to create a Double Dimensional Array (DDA) as:
Char ch=[ ] = new ch[3][3];
The program stores nine different characters in Double Dimensional Array. Display the characters of the left diagonal.
s     p     k
g     u     f
b     c     n
Sample Output: s, u, n

Read Answer
Write a program to create a Double Dimensional Array (DDA) as: Char ch[ ][ ] = new ch[3][3];

This program creates a 3x3 Double Dimensional Array of characters, stores nine different characters, and displays the vowels from the array.

Read more
Write a program to create a Double Dimensional Array (DDA) as:
Char ch[ ][ ] = new ch[3][3];
The program stores nine different characters in Double Dimensional Array. Display the characters, which are vowels.
p     e     r
w     d     a
u     m     k
Sample Output: e, a, u

Read Answer
Write a program in Java to create a Double Dimensional Array as int m[ ]=new int m[3][3] and to produce a printout as follows:

Below is the Java program to create a 3x3 double-dimensional array and produce the specified printout. This involves initializing the array and printing two different patterns.

Read more
Write a program in Java to create a Double Dimensional Array as int m[ ]=new int m[3][3] and to produce a printout as follows:
 0     1     0                                              1     0     0
 1     0     1                                              0     1     0                   
 0     1     0                                              0     0     1

Read Answer
If arrays M and M+N are as shown below, Write a program in Java to find the array N.

This Java program calculates array � from the given arrays � and � + � using element-wise subtraction and displays the resulting matrix.

Read more
If arrays M and M+N are as shown below, Write a program in Java to find the array N.
            -1     0     2                                         -6     9     4
M =     -3     -1     6                 and   M+N =    4     5     0
             4     3     -1                                          1    -2     -3

Read Answer
Using a Java program, create a 3*3 matrix and store the first nine natural numbers row-wise.

This Java program creates a 3x3 matrix with the first nine natural numbers, calculates row sums, column sums, and diagonal sums (left and right), and displays the results.

Read more
   Using a Java program, create a 3*3 matrix and store the first nine natural numbers row-wise.
Now write a program to print the following output:
a)      Sum of the numbers in each row
b)      Sum of the numbers in each column
c)      Sum of the numbers in the left diagonal
d)      Sum of the numbers in the right diagonal
1     2     3
4     5     6
7     8     9

Read Answer
Write a program to store 6 elements in an array P and 4 elements in an array Q. Now, produce a third array R, containing all the elements of array P and Q.

This Java program merges two arrays, P (6 elements) and Q (4 elements), into a third array R and displays the combined result.

Read more
Write a program to store 6 elements in an array P and 4 elements in an array Q. Now, produce a third array R, containing all the elements of array P and Q. Display the resultant array.

Input

Input

Output

P[ ]

Q[ ]

R[ ]

4

19

4

6

23

6

1

7

1

2

8

2

3

 

3

10

 

10

 

 

19

 

 

23

 

 

7

 

 

8

Read Answer
The annual examination result of 50 students in a class is tabulated in an S.D.A as follows:

This Java program stores roll numbers and marks for 50 students in 3 subjects, calculates the average for each student, and identifies those with averages above and below 80.

Read more
The annual examination result of 50 students in a class is tabulated in an S.D.A as follows:

Roll No.

Subject A

Subject B

Subject C

………………….

………………….

………………….

………………….

………………….

………………….

………………….

………………….

………………….

………………….

………………….

………………….

   Write a program to read the data, calculate and display the following:
a)      Average mark obtained by each student.
b)      Print the roll number and the average marks of the students whose average is above 80.
c)      Print the roll number and the average marks of the students whose average is below 80.

Read Answer
Write a program to store 20 numbers in a Single Dimensional Array (SDA). Now, display only those numbers having complete square roots.

This Java program stores 20 numbers in an array and displays only those numbers that are perfect squares by checking if their square roots are integers.

Read more
Write a program to store 20 numbers in a Single Dimensional Array (SDA). Now, display only those numbers having complete square roots.
Sample Input:

n[0]

n[1]

n[2]

n[3]

n[4]

n[5]

n[6]

n[7]

n[8]

n[9]

12

45

49

78

64

77

81

99

45

33

 Sample Output: 49, 64, 81
Read Answer
You want to know the ASCII value of all the names of your friends.

This Java program stores 20 names, calculates the sum of ASCII values of the characters in each name, and displays the name with the highest sum of ASCII values.

Read more

You want to know the ASCII value of all the names of your friends. Write a program to store 20 names in a Single Dimensional Array (SDA). Now, create another array, which stores ASCII values of the corresponding names. Finally, display the name having the highest ASCII value among the names.

Read Answer
Write a program to initialize an array of 10 names and initialize another array with their respective telephone numbers.

This Java program allows the user to search for a name in a list of 10 names, and if found, it displays the name along with its corresponding telephone number. The search is case-insensitive.

Read more

Write a program to initialize an array of 10 names and initialize another array with their respective telephone numbers. Search for a name by the User, in the list. If found, display ‘Search Successful’ and print the name along with the telephone number, otherwise display ‘Search Unsuccessful. Name not enlisted’.

Read Answer
Write a program in Java to store 10 words in a single-dimensional array. Display only those words that are Palindrome.

This Java program stores 10 words in an array and displays only those that are palindromes. A palindrome is a word that reads the same forwards and backwards, and this is checked using a simple loop.

Read more
Write a program in Java to store 10 words in a single-dimensional array. Display only those words that are Palindrome.
Sample Input     : MADAM, TEACHER, SCHOOL, ABBA, ……….
Sample Output  : MADAM
                               ABBA
                              …………
                              …………

Read Answer
Store 5 words in a Single Dimensional Array and frame a new word by taking out the first character of each word. Arrange the alphabets of the new word in ascending order and display the resultant word.

This Java program takes 5 words from the user, extracts the first letter of each word, sorts them in ascending order, and displays the resultant word. The sorting is done using Java's Arrays.sort() method.

Read more
Write a program in Java to store 5 words in a single-dimensional array and frame a new word by taking out the first character of each word. Arrange the alphabet of the new word in ascending order and display the resultant word.
Sample Input: Computer, History, Physics, Biology, English
Sample Word: CHPBE
Sample Output: BCEHP

Read Answer
Write a program in Java to store word/names in a Single Dimensional Array. Display only those word/names which begin with a vowel and also and with a vowel.

This Java program stores 10 words/names in an array and displays only those that begin and end with a vowel. The program uses a helper method to check if a character is a vowel, ensuring case insensitivity.

Read more
Write a program in Java to store words/names in a Single Dimensional Array. Display only those words/names which begin with a vowel and also with a vowel.
Sample Input      : Eshita, Monalisha, Daniel, India, …………..
Sample Output   : Eshita
                                India
                               …………..
                               …………..

Read Answer
Write a program in Java to store 10 city names in a Single Dimensional Array. Display only those words/names which begin with a consonant but end with a vowel.

This Java program stores 10 city names in an array and filters out those that begin with a consonant and end with a vowel. The program then displays the filtered city names in the output.

Read more
Write a program in Java to store 10 city names in a Single Dimensional Array. Display only those words/names which begin with a consonant but end with a vowel.
Sample Input      : Kolkata, Delhi, Bangalore, Jamshedpur, Bokaro, …………
Sample Output   : Kolkata
                                Delhi
                                Bangalore
                                Bokaro
                                ………….
                                ………….

Read Answer
Write a program in Java, using arrays: a) To store the Roll No. Name and Marks of six subjects for 100 students......

This Java program calculates the percentage and assigns grades to 100 students based on their marks in six subjects. It validates marks, computes percentages, and displays results in a tabular format.

Read more
    Write a program in Java, using arrays:
a)      To store the Roll No. Name and Marks of six subjects for 100 students.
b)      Calculate the percentage of marks obtained by each candidate. The maximum marks in each subject are 100.
c)      Calculate the Grade as per the given criteria:

Percentage Marks

Grade

From 80 to 100

A

From 60 to 79

B

From 40 to 59

C

Less than 40

D

Read Answer
Write a program to input the names and marks of the students in the subject. Calculate and display:

This Java program stores names and marks of 50 students in a subject. It calculates the average marks, identifies the highest mark, and displays the name of the top scorer with their marks. Input validation ensures marks are between 0 and 100.

Read more
The marks obtained by 50 students in subjects are tabulated as follows:-
        Name                                   Marks
………………                    ……………….
………………                    ……………….
………………                    ……………….
     Write a program to input the names and marks of the students in the subject. Calculate and display:
a)      The subject average marks (subject average marks = subject total/50)
b)      The highest mark in the subject and the name of the student. (The maximum marks in the subject are 100)

Read Answer
A class teacher wants to keep the records of 40 students in her class along with the names and marks obtained in Eng, Hindi, Math, Science and Computer Science in a D.D.A of 40*5.

This Java program stores the names and marks of 40 students in 5 subjects using arrays. Teachers can search for a student by name to view their marks and total. Case-insensitive search is implemented for flexibility.

Read more

A class teacher wants to keep the records of 40 students in her class along with the names and marks obtained in Eng, Hindi, Math, Science and Computer Science in a D.D.A of 40*5. When the teacher enters the name of a student as an input, the program must display the name, marks obtained in 5 subjects and the total. Write a program in Java to perform the task.

Read Answer
A Metropolitan Hotel has 5 floors & 10 rooms in each floor. The names of the visitors are entered in D.D.A as [5][10].

This Java program stores visitor names for a 5-floor, 10-room hotel in a 2D array. It allows the user to search for a visitor by name and displays their floor and room number, or informs if they are not found.

Read more

A Metropolitan Hotel has 5 floors & 10 rooms on each floor. The names of the visitors are entered in D.D.A as [5][10]. The Hotel Manager wants to know from the “Enquiry” about the position of a visitor (i.e. floor no. and room no.) as soon as he enters the name of the visitor. Write a program in Java to perform the above task.

Read Answer
A Departmental Shop has 5 stores and 6 departments. The monthly sale of the Department is kept in the D.D.A as int m[5][6].

This Java program calculates the total monthly sales for each store and department in a departmental shop using a 2D array. User inputs sales data, and the program computes and displays the totals for rows (stores) and columns (departments).

Read more
A Departmental Shop has 5 stores and 6 departments. The monthly sale of the Department is kept in the D.D.A as int m[5][6]. The Manager of the shop wants to know the total monthly sales of each store and each department at any time. WAP in Java to perform the given task.
[Hint: Number of stores as rows and Number of departments as columns.]

Read Answer