[Go to site: main page, start]

0% found this document useful (0 votes)
6 views5 pages

Java Programs Aim and Algorithm

The document outlines various Java programming tasks, each with a specific aim and algorithm. It includes programs for generating prime numbers, matrix multiplication, file character counting, random number generation, string manipulation, multi-threading, exception handling, and GUI applications. Each task is presented with a step-by-step algorithm to guide implementation.

Uploaded by

stharsana955
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Java Programs Aim and Algorithm

The document outlines various Java programming tasks, each with a specific aim and algorithm. It includes programs for generating prime numbers, matrix multiplication, file character counting, random number generation, string manipulation, multi-threading, exception handling, and GUI applications. Each task is presented with a step-by-step algorithm to guide implementation.

Uploaded by

stharsana955
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA PROGRAMS - AIM AND ALGORITHM

1. Prime Numbers up to N

Aim: To write a Java program to display all prime numbers up to a given integer.

• Start
• Read the integer N from user
• For each number from 2 to N
• Check if the number is divisible by any number between 2 and i-1
• If not divisible, print the number
• Stop

2. Matrix Multiplication

Aim: To multiply two matrices using Java.

• Start
• Initialize first and second matrices
• Check if multiplication is possible (c1 == r2)
• Use three nested loops to multiply matrices
• Store result in product matrix
• Display result matrix
• Stop

3. Count Characters, Words and Lines in File

Aim: To count number of characters, words and lines in a text file.

• Start
• Open file using BufferedReader
• Read file line by line
• Count lines
• Count characters using length()
• Split line into words and count
• Display counts
• Stop
4. Generate Random Numbers

Aim: To generate random numbers between given limits.

• Start
• Create Random object
• Generate random number between min and max
• Print the number
• Stop

5. String Manipulation using Character Array

Aim: To perform string operations using character array.

• Start
• Read two strings
• Convert strings to char arrays
• Find length using array length
• Find character at given position
• Concatenate arrays
• Display results
• Stop

6. String Operations using String Class

Aim: To perform concatenation, substring search and extraction.

• Start
• Read two strings
• Concatenate using + operator
• Check substring using contains()
• Extract substring using substring()
• Display results
• Stop

7. String Operations using StringBuffer

Aim: To perform length, reverse and delete operations using StringBuffer.

• Start
• Read input string
• Create StringBuffer object
• Find length using length()
• Reverse using reverse()
• Delete substring using delete()
• Display results
• Stop

8. Multi-thread Even/Odd Program

Aim: To generate random numbers and compute square or cube using threads.

• Start
• Create generator thread
• Generate random number every second
• If number is even, compute square
• If number is odd, compute cube
• Display results
• Stop

9. Asynchronous Thread Printing

Aim: To print numbers 1–10 and 90–100 using two threads.

• Start
• Create Thread-1 for 1 to 10
• Create Thread-2 for 90 to 100
• Start both threads
• Print numbers asynchronously
• Stop

10. Exception Handling Demo

Aim: To demonstrate different Java exceptions.

• Start
• Use try-catch block
• Demonstrate ArithmeticException
• Demonstrate NumberFormatException
• Demonstrate ArrayIndexOutOfBoundsException
• Demonstrate NegativeArraySizeException
• Stop

11. File Information Program

Aim: To display file properties.

• Start
• Read file name from user
• Create File object
• Check existence
• Check readability and writability
• Display file type and length
• Stop

12. Text Editor with Font Controls

Aim: To change font size and style using Swing controls.

• Start
• Create JFrame and JTextArea
• Add slider for font size
• Add checkboxes for Bold and Italic
• Apply selected font settings
• Display frame
• Stop

13. Mouse Event Handling

Aim: To handle mouse events and display event name.

• Start
• Create JFrame
• Add MouseAdapter
• Override mouse event methods
• Display event name at center
• Stop
14. Simple Calculator using GridLayout

Aim: To create a calculator using Swing components.

• Start
• Create JFrame and JTextField
• Add buttons using GridLayout
• Handle operations using ActionListener
• Handle divide by zero exception
• Display result
• Stop

15. Traffic Light Simulation

Aim: To simulate traffic light using radio buttons.

• Start
• Create JFrame
• Add radio buttons for Red, Yellow, Green
• Display message based on selection
• Change message color accordingly
• Stop

You might also like