Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Handwritten solved Java tasks.

Rating
-
Sold
-
Pages
6
Uploaded on
08-05-2026
Written in
2025/2026

This PDF contains handwritten solved Java tasks that will help you if you are a beginner and want to learn Java. It has easy ways to solve Java tasks. Use this as a study guide to learn.

Institution
Course

Content preview

Java Programming Tasks Collection
Cleaned & Formatted Java Practice Programs
Course: Java Programming
Institution: GIFT University
Document Type: Practice Tasks & Code Exercises




Table of Contents
1. Prime Number Checker
2. Seconds to Time Units Converter
3. Word Information Analyzer
4. Area & Perimeter Calculator
5. Character Position Finder
6. User Input & Validation




Task 1 — Prime Number Checker
Description

This program checks whether a number entered by the user is prime or composite.


Java Code


import java.util.Scanner;

public class Task1 {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.println("Enter any number:");
int number = input.nextInt();

isPrime(number);
}

public static void isPrime(int number) {




1

, if (number < 2) {
System.out.println("Invalid number");
return;
}


int count = 0;

for (int i = 1; i <= number; i++) {
if (number % i == 0) {
count++;
}
}

if (count == 2) {
System.out.println("Prime");
} else {
System.out.println("Composite");
}
}
}




Task 2 — Seconds to Time Units Converter
Description

This program converts seconds into hours, minutes, seconds, and milliseconds.


Java Code


import java.util.Scanner;

public class Task2 {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.print("Enter any value: ");
int seconds = input.nextInt();

secondsToTimeUnits(seconds);
}

public static void secondsToTimeUnits(double seconds) {




2

Written for

Institution
Course

Document information

Uploaded on
May 8, 2026
Number of pages
6
Written in
2025/2026
Type
Class notes
Professor(s)
Sir john mandava
Contains
All classes

Subjects

$7.29
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
syedaakifazainab

Get to know the seller

Seller avatar
syedaakifazainab GIFT University
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 day
Number of followers
0
Documents
3
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions