SlideShare a Scribd company logo
Computational Problem
Solving
Table of Contents
Java Introduction
Data Types
Sum of two complex numbers
Multiply and Divide
Conditional Control Structure
Coin Change
Odd or even
Uppercase or Lowercase
Profit or Loss
Sum of N numbers
Factorial of a number
Fibonacci series
Armstrong Number
Reverse a number
Linear Search
Matrix Multiplication
Reverse an array
Minimum Sum
Remove duplicates
Closest Pair
String validation
Anagrams
Twin Prime
Vowel count
Maximum Sum
Longest Palindrome
Missing number
Reverse vowels
Reverse only letters
Power of three
Convert number to Hex
Basic Calculator
Perfect Squares
Spiral Matrix
Permutations
Student Attendance Record
Name password generation
Reverse String
Count even digits
Number Series
Diamond Series
Introduction
❑ Java is a general-purpose, high-level programming language .
❑ Java is a programming language that James Gosling developed at
Sun Microsystems_Inc in the year 1995, which later on was taken
into possession by the Oracle Corporation in 2009.
❑ Java Virtual Machine interprets the bytecode and converts it to
platform specific machine code. Hence, Java is also called a
platform-independent programming language.
❑ Java is a class-based object-oriented programming language that
implements the principle of write once code anywhere.
Features of Java
1. Simple
2. Object-Oriented
3. Portable
4. Platform independent
5. Secured
6. Robust
7. Architecture neutral
8. Interpreted
9. High Performance
10. Multithreaded
11. Distributed
12. Dynamic
Applications of Java
o Mobile App Development
o Desktop GUI Applications
o Web-based Applications
o Gaming Applications
o Big Data Technologies
o Distributed Applications
o Cloud-based Applications
o IoT Applications
o Enterprise Applications
o Scientific Applications
Data Types
There are two types of data types in Java:
Primitive data types : The primitive data types include:
o boolean data type
o byte data type
o char data type
o short data type
o int data type
o long data type
o float data type
o double data type
Non-primitive data types : The non-primitive data types include :
o Classes
o Interfaces
o Arrays.
Computational Problem Solving 004 (1).pptx (1).pdf
Example
int myNum = 5; // Integer (whole number)
float myFloatNum = 5.99f; // Floating point number
char myLetter = 'D’; // Character
boolean myBool = true; // Boolean
double d2 = 1.234e2 // Double
String myText = "Hello"; // String
int arr[] = new int[100]; // Array
If-else Statement
The if Statement:
If(condition) {
//block of code to be executed if the condition is true
}
Example :
int x = 20;
int y = 18;
if (x > y)
{
System.out.println("x is greater than y");
}
The else Statement:
If(condition) {
//block of code to be executed if the condition is true
}
else {
// block of code to be executed if the condition is false
}
Example :
int x = 20;
if (x > 18){
System.out.println("x is greater than 18");
}
else {
System.out.println("x is less than 18");
}
The else if Statement:
If(condition 1) {
//block of code to be executed if the condition 1 is true
} else if (condition 2) {
// block of code to be executed if the condition 1 is false and condition 2 is true
} else {
// block of code to be executed if the condition 1 is false and condition 2 is false
}
Example : int x = 0;
if (x > 0){
System.out.println("x is greater than 0");
} else if (x < 0) {
System.out.println("x is less than 0");
} else {
System.out.println("x is 0");
}
Loops in Java
for Loop:
for(initializing statement;testing condition;increment/decrement)
{
//code to be iterated
}
Example :
for (i = 0; i <= 10; i++)
{
System.out.println("Value of i = " + i);
}
while Loop:
while(boolean condition)
{
//statements;
}
Example :
while (i < 5) {
System.out.println("The value of i is = " + i);
i++;
}
do while Loop:
do {
statement(s);
} while(test-expression) ;
Example :
char ch = 'A' ;
do
{
System.out.println( ch + " " );
ch++;
} while(ch <= 'Z');
Arrays in Java
• In Java, all arrays are dynamically allocated.
• Arrays are stored in contagious memory.
• Since arrays are objects in Java, we can find their length using the
object property length.
• A Java array variable can also be declared like other variables with
[] after the data type.
• Java array can also be used as a static field, a local variable, or a
method parameter.
• The size of an array must be specified by int or short value and not
long.
Instantiating array:
var-name = new type [size];
int intArray[]; //declaring array
intArray = new int[20]; // allocating memory to array
int[] intArray = new int[20]; // combining both statements in one
Array Literal:
int[] intArray = new int[]{ 1,2,3,4,5,6,7,8,9,10 };
// Declaring array literal
THANK YOU

More Related Content

Similar to Computational Problem Solving 004 (1).pptx (1).pdf (20)

PPTX
COMPUTER PROGRAMMING LANGUAGE.pptx
SofiaArquero2
 
PPTX
Java Android Programming for MAD lab Fundamentals
Abcd463572
 
PPTX
Java data types
AbhishekMondal42
 
PPTX
JPC#8 Introduction to Java Programming
Pathomchon Sriwilairit
 
PPTX
Java Programming
RubaNagarajan
 
PPTX
Java introduction
Samsung Electronics Egypt
 
PDF
KeyJavaConcepts to EnhanceYour AutomationTesting Skills
digitaljignect
 
PPTX
Android webinar class_java_review
Edureka!
 
PPTX
Java fundamentals
Jayfee Ramos
 
PPSX
DISE - Windows Based Application Development in Java
Rasan Samarasinghe
 
PPSX
Java session3
Jigarthacker
 
PPT
Introduction to-programming
BG Java EE Course
 
PDF
Java data types, variables and jvm
Madishetty Prathibha
 
PPTX
Introduction to java
rishi ram khanal
 
PPTX
L2 datatypes and variables
teach4uin
 
PPTX
JAVA LESSON-01.pptx
StephenOczon1
 
PPTX
Advanced java programming - DATA TYPES, VARIABLES, ARRAYS
vijayalakshmis184431
 
PPTX
Computer Programming Java Data Types.pptx
MarianneIsid
 
PPTX
Class 8 - Java.pptx
sreedevi143432
 
PPTX
Unit No. 1 Introduction to Java.pptx
DrYogeshDeshmukh1
 
COMPUTER PROGRAMMING LANGUAGE.pptx
SofiaArquero2
 
Java Android Programming for MAD lab Fundamentals
Abcd463572
 
Java data types
AbhishekMondal42
 
JPC#8 Introduction to Java Programming
Pathomchon Sriwilairit
 
Java Programming
RubaNagarajan
 
Java introduction
Samsung Electronics Egypt
 
KeyJavaConcepts to EnhanceYour AutomationTesting Skills
digitaljignect
 
Android webinar class_java_review
Edureka!
 
Java fundamentals
Jayfee Ramos
 
DISE - Windows Based Application Development in Java
Rasan Samarasinghe
 
Java session3
Jigarthacker
 
Introduction to-programming
BG Java EE Course
 
Java data types, variables and jvm
Madishetty Prathibha
 
Introduction to java
rishi ram khanal
 
L2 datatypes and variables
teach4uin
 
JAVA LESSON-01.pptx
StephenOczon1
 
Advanced java programming - DATA TYPES, VARIABLES, ARRAYS
vijayalakshmis184431
 
Computer Programming Java Data Types.pptx
MarianneIsid
 
Class 8 - Java.pptx
sreedevi143432
 
Unit No. 1 Introduction to Java.pptx
DrYogeshDeshmukh1
 

Recently uploaded (20)

PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Executive Business Intelligence Dashboards
vandeslie24
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Ad

Computational Problem Solving 004 (1).pptx (1).pdf

  • 2. Table of Contents Java Introduction Data Types Sum of two complex numbers Multiply and Divide Conditional Control Structure Coin Change Odd or even Uppercase or Lowercase Profit or Loss Sum of N numbers Factorial of a number Fibonacci series Armstrong Number Reverse a number Linear Search Matrix Multiplication Reverse an array Minimum Sum Remove duplicates Closest Pair String validation Anagrams Twin Prime Vowel count Maximum Sum Longest Palindrome Missing number Reverse vowels
  • 3. Reverse only letters Power of three Convert number to Hex Basic Calculator Perfect Squares Spiral Matrix Permutations Student Attendance Record Name password generation Reverse String Count even digits Number Series Diamond Series
  • 4. Introduction ❑ Java is a general-purpose, high-level programming language . ❑ Java is a programming language that James Gosling developed at Sun Microsystems_Inc in the year 1995, which later on was taken into possession by the Oracle Corporation in 2009. ❑ Java Virtual Machine interprets the bytecode and converts it to platform specific machine code. Hence, Java is also called a platform-independent programming language. ❑ Java is a class-based object-oriented programming language that implements the principle of write once code anywhere.
  • 5. Features of Java 1. Simple 2. Object-Oriented 3. Portable 4. Platform independent 5. Secured 6. Robust 7. Architecture neutral 8. Interpreted 9. High Performance 10. Multithreaded 11. Distributed 12. Dynamic
  • 6. Applications of Java o Mobile App Development o Desktop GUI Applications o Web-based Applications o Gaming Applications o Big Data Technologies o Distributed Applications o Cloud-based Applications o IoT Applications o Enterprise Applications o Scientific Applications
  • 7. Data Types There are two types of data types in Java: Primitive data types : The primitive data types include: o boolean data type o byte data type o char data type o short data type o int data type o long data type o float data type o double data type Non-primitive data types : The non-primitive data types include : o Classes o Interfaces o Arrays.
  • 9. Example int myNum = 5; // Integer (whole number) float myFloatNum = 5.99f; // Floating point number char myLetter = 'D’; // Character boolean myBool = true; // Boolean double d2 = 1.234e2 // Double String myText = "Hello"; // String int arr[] = new int[100]; // Array
  • 10. If-else Statement The if Statement: If(condition) { //block of code to be executed if the condition is true } Example : int x = 20; int y = 18; if (x > y) { System.out.println("x is greater than y"); }
  • 11. The else Statement: If(condition) { //block of code to be executed if the condition is true } else { // block of code to be executed if the condition is false } Example : int x = 20; if (x > 18){ System.out.println("x is greater than 18"); } else { System.out.println("x is less than 18"); }
  • 12. The else if Statement: If(condition 1) { //block of code to be executed if the condition 1 is true } else if (condition 2) { // block of code to be executed if the condition 1 is false and condition 2 is true } else { // block of code to be executed if the condition 1 is false and condition 2 is false } Example : int x = 0; if (x > 0){ System.out.println("x is greater than 0"); } else if (x < 0) { System.out.println("x is less than 0"); } else { System.out.println("x is 0"); }
  • 13. Loops in Java for Loop: for(initializing statement;testing condition;increment/decrement) { //code to be iterated } Example : for (i = 0; i <= 10; i++) { System.out.println("Value of i = " + i); }
  • 14. while Loop: while(boolean condition) { //statements; } Example : while (i < 5) { System.out.println("The value of i is = " + i); i++; }
  • 15. do while Loop: do { statement(s); } while(test-expression) ; Example : char ch = 'A' ; do { System.out.println( ch + " " ); ch++; } while(ch <= 'Z');
  • 16. Arrays in Java • In Java, all arrays are dynamically allocated. • Arrays are stored in contagious memory. • Since arrays are objects in Java, we can find their length using the object property length. • A Java array variable can also be declared like other variables with [] after the data type. • Java array can also be used as a static field, a local variable, or a method parameter. • The size of an array must be specified by int or short value and not long.
  • 17. Instantiating array: var-name = new type [size]; int intArray[]; //declaring array intArray = new int[20]; // allocating memory to array int[] intArray = new int[20]; // combining both statements in one Array Literal: int[] intArray = new int[]{ 1,2,3,4,5,6,7,8,9,10 }; // Declaring array literal