SlideShare a Scribd company logo
1 of 14
Download to read offline
Pimp UR Knowledge II
Intro. To programming using Java
SESSION NO.2
What Are We Going To Do
• 2.1. Session’s Quiz
• 2.2. Quick Revision
• 2.3. Java tools(If statements and loops)
• 2.4. General Examples
• 2.5. Session’s Quiz
• 2.6. Session’s Report
• 2.7. Questions time
QUIZ
• Write a Java program that reads 2 numbers and prints out their sum.
Java Tools
If Statements:
• It’s normally as the if statements we use in verbal language:
• If … Condition … Answer of Condition >and> If not … Another Answer
Form:
if(Condition){
Answer Code}
else {
the other Answer Code}
Java Tools
Loops:
• Loops are used to repeat a piece of your code several times which could be
user defined or conditioned.
Form:
For( int i = start ; i < finish ; i(+or-)=step)
{Code}
FINALLY!
Good programming style :
• Use good names for variables and methods
• Add whitespaces
• Don't duplicate tests
GENERAL EXAMPLES
Lets Play Java 
EXAMPLE 1
Make a Java Program to simulate a waiter’s job in a restaurant where the
customer is asked for his desired food and dessert after the waiter tells the
menu. After the customer finishes his order he is told the cost.
Pizza Burger Grilled Fish Chocolate
Cake
Juice Coke
40 17 60 15 10 5
EXAMPLE 2
Write a salary program for a company to calculate the salary of the employee
according to the following table
Worker Type Base Salary
For 40
hours/hour
Over time
>40
Over Time
>60
Taxes
Worker 50 *1.5 *2 3%
Engineer 65 *2 *3 5%
Manager 80 *2 *3 7%
CEO  150 _______ ______ 10%
EXAMPLE 3
Design a Java Program to draw a Diamond shape using any symbol
EXAMPLE 4
• Write a Java Program to print out a sequence which it’s Start, Step,
Kind(Arithmetic or Geometric), End. Are Given to you as an input from the
user.
QUIZ
Design a Java Program to find numbers that it’s remainder after division on 3,
4, 5, 6, 7, 8 is 2. And Prints them out.
Design a Java Program that reads a number and prints out the Odd, Even,
Prime numbers till this number separated.
REPORT
Design a Java program that reads numbers as an input then puts them in an
array then:
• Sort Them in an ( ascending, descending ) an save both of them in a separate
array.
• Find The Maximum and Minimum Value and it’s Location in the array.
• Give an option to search for a value if available in the array or not if
available show the user the location
Session 2 of programming

More Related Content

What's hot (6)

Practical unit testing tips
Practical unit testing tipsPractical unit testing tips
Practical unit testing tips
 
Testcase
TestcaseTestcase
Testcase
 
Hello World e4 Application Part 6
Hello World e4 Application Part 6Hello World e4 Application Part 6
Hello World e4 Application Part 6
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Bc0051 – system software
Bc0051 – system softwareBc0051 – system software
Bc0051 – system software
 
Looping
LoopingLooping
Looping
 

Similar to Session 2 of programming

Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
iamluqman0403
 
TOPIC-1-Introduction and Preliminaries.pdf
TOPIC-1-Introduction and Preliminaries.pdfTOPIC-1-Introduction and Preliminaries.pdf
TOPIC-1-Introduction and Preliminaries.pdf
EjazAlam23
 
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
Week 2PRG 218   Variables and Input and Output OperationsWrite.docxWeek 2PRG 218   Variables and Input and Output OperationsWrite.docx
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
melbruce90096
 
javabasics_ programming development chapter01
javabasics_ programming development chapter01javabasics_ programming development chapter01
javabasics_ programming development chapter01
Udeshg90
 
Java Script web development - Engineering
Java Script web development - EngineeringJava Script web development - Engineering
Java Script web development - Engineering
DineshKumar A
 
Intro to javascript (6:19)
Intro to javascript (6:19)Intro to javascript (6:19)
Intro to javascript (6:19)
Thinkful
 
Software development slides
Software development slidesSoftware development slides
Software development slides
iarthur
 
Week 2PRG 218 Variables and Input and Output OperationsYou w.docx
Week 2PRG 218   Variables and Input and Output OperationsYou w.docxWeek 2PRG 218   Variables and Input and Output OperationsYou w.docx
Week 2PRG 218 Variables and Input and Output OperationsYou w.docx
melbruce90096
 

Similar to Session 2 of programming (20)

Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
 
TOPIC-1-Introduction and Preliminaries.pdf
TOPIC-1-Introduction and Preliminaries.pdfTOPIC-1-Introduction and Preliminaries.pdf
TOPIC-1-Introduction and Preliminaries.pdf
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
 
Software Design
Software DesignSoftware Design
Software Design
 
Overview of Software Engineering Principles - SCPS311.pptx
Overview of Software Engineering Principles - SCPS311.pptxOverview of Software Engineering Principles - SCPS311.pptx
Overview of Software Engineering Principles - SCPS311.pptx
 
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
Week 2PRG 218   Variables and Input and Output OperationsWrite.docxWeek 2PRG 218   Variables and Input and Output OperationsWrite.docx
Week 2PRG 218 Variables and Input and Output OperationsWrite.docx
 
javabasics_ programming development chapter01
javabasics_ programming development chapter01javabasics_ programming development chapter01
javabasics_ programming development chapter01
 
Session 1 of programming
Session 1 of programmingSession 1 of programming
Session 1 of programming
 
Java Script web development - Engineering
Java Script web development - EngineeringJava Script web development - Engineering
Java Script web development - Engineering
 
Intro to javascript (6:19)
Intro to javascript (6:19)Intro to javascript (6:19)
Intro to javascript (6:19)
 
Software development slides
Software development slidesSoftware development slides
Software development slides
 
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
 
MPP-UPNVJ
MPP-UPNVJMPP-UPNVJ
MPP-UPNVJ
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
Topic production code
Topic production codeTopic production code
Topic production code
 
Programming Sessions KU Leuven - Session 02
Programming Sessions KU Leuven - Session 02Programming Sessions KU Leuven - Session 02
Programming Sessions KU Leuven - Session 02
 
Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017
 
Week 1
Week 1Week 1
Week 1
 
Week 2PRG 218 Variables and Input and Output OperationsYou w.docx
Week 2PRG 218   Variables and Input and Output OperationsYou w.docxWeek 2PRG 218   Variables and Input and Output OperationsYou w.docx
Week 2PRG 218 Variables and Input and Output OperationsYou w.docx
 

More from Ramy F. Radwan (8)

Literature review for managing projects effectively
Literature review for managing projects effectivelyLiterature review for managing projects effectively
Literature review for managing projects effectively
 
Applying agile to large scale corporations - Ramy F Radwan
Applying agile to large scale corporations  - Ramy F RadwanApplying agile to large scale corporations  - Ramy F Radwan
Applying agile to large scale corporations - Ramy F Radwan
 
Ramys resume
Ramys resumeRamys resume
Ramys resume
 
NASA space apps guide for android
NASA space apps guide for androidNASA space apps guide for android
NASA space apps guide for android
 
certificate
certificatecertificate
certificate
 
Udacity Reviews
Udacity ReviewsUdacity Reviews
Udacity Reviews
 
CIEians arduino
CIEians arduinoCIEians arduino
CIEians arduino
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 

Recently uploaded

Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
drm1699
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Lisi Hocke
 

Recently uploaded (20)

Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
 
Rapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and InsightsRapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and Insights
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 
architecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdfarchitecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdf
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
 
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
 
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Turfloop ](+27832195400*)[ 🏥 Women's Abortion Clinic in ...
 

Session 2 of programming

  • 1. Pimp UR Knowledge II Intro. To programming using Java SESSION NO.2
  • 2. What Are We Going To Do • 2.1. Session’s Quiz • 2.2. Quick Revision • 2.3. Java tools(If statements and loops) • 2.4. General Examples • 2.5. Session’s Quiz • 2.6. Session’s Report • 2.7. Questions time
  • 3. QUIZ • Write a Java program that reads 2 numbers and prints out their sum.
  • 4. Java Tools If Statements: • It’s normally as the if statements we use in verbal language: • If … Condition … Answer of Condition >and> If not … Another Answer Form: if(Condition){ Answer Code} else { the other Answer Code}
  • 5. Java Tools Loops: • Loops are used to repeat a piece of your code several times which could be user defined or conditioned. Form: For( int i = start ; i < finish ; i(+or-)=step) {Code}
  • 6. FINALLY! Good programming style : • Use good names for variables and methods • Add whitespaces • Don't duplicate tests
  • 8. EXAMPLE 1 Make a Java Program to simulate a waiter’s job in a restaurant where the customer is asked for his desired food and dessert after the waiter tells the menu. After the customer finishes his order he is told the cost. Pizza Burger Grilled Fish Chocolate Cake Juice Coke 40 17 60 15 10 5
  • 9. EXAMPLE 2 Write a salary program for a company to calculate the salary of the employee according to the following table Worker Type Base Salary For 40 hours/hour Over time >40 Over Time >60 Taxes Worker 50 *1.5 *2 3% Engineer 65 *2 *3 5% Manager 80 *2 *3 7% CEO  150 _______ ______ 10%
  • 10. EXAMPLE 3 Design a Java Program to draw a Diamond shape using any symbol
  • 11. EXAMPLE 4 • Write a Java Program to print out a sequence which it’s Start, Step, Kind(Arithmetic or Geometric), End. Are Given to you as an input from the user.
  • 12. QUIZ Design a Java Program to find numbers that it’s remainder after division on 3, 4, 5, 6, 7, 8 is 2. And Prints them out. Design a Java Program that reads a number and prints out the Odd, Even, Prime numbers till this number separated.
  • 13. REPORT Design a Java program that reads numbers as an input then puts them in an array then: • Sort Them in an ( ascending, descending ) an save both of them in a separate array. • Find The Maximum and Minimum Value and it’s Location in the array. • Give an option to search for a value if available in the array or not if available show the user the location