SlideShare a Scribd company logo
TEST PROGRAM TAKEN FROM THE
PREVIOUS LESSONS
REMINDERS IN CREATING A CLASS
Make sure that
your class is inside
of the scr
BASIC OPERATORS AND ESCAPE
SEQUENCEimport java.util.*; //notes this called source file
public class BasicOperators {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner (System.in);
int L = 12;
float W = (float) 35.4;
float A =0;
//find the area of a rectangle
A = L * W;
System.out.println("The area of rectangle is:" +
A);
System.out.println("**************************");
//find the speed
float distance = 3; // 3km.
float time = 2;// 2 hrs.
float Speed;
Speed = distance / time;
System.out.println("The speed is:" + Speed);
System.out.println("**************************");
CONTINUATION:
//calculating my age; example only
int birthyear = 1992;
int presentyear = 2020;
int age;
age = presentyear - birthyear;
System.out.println("My age is :" + age);
System.out.println("***********************");
//calculating of modulus;
//calculating of modulus;
int V = 7,S = 5, m =0;
m = V % S;
System.out.println("The remainder oft" + V +
"tand " + S + "tist" + m); //note I uisng t
escape sequence for tab
OUTPUT:
The area of rectangle is:424.80002
************************************************
The speed is:1.5
************************************************
My age is :28
************************************************
The remainder of 7 and 5 is 2
IDENTIFYING THE PLACE VALUE OF
THE DIGIT
import java.util.*;
public class PlaceValue {
public static void main(String arg[]) {
Scanner Input = new Scanner (System.in);
//Variable Declaration
int num,Thousand,Hundreds,Tens,Ones;
int result1,result2,result3;
System.out.print("Enter number:");
num = Input.nextInt();
System.out.println("There are:");
//calculating the value of thousand
Thousand = num/1000;
System.out.println(Thousand + "Thousands");
//calculating the value of hundreds
result1 = num%1000;
Hundreds = result1/100;
System.out.println(Hundreds + "Hundreds");
//calculating the value of tens
result2 = num%100;
Tens = result2/10;
System.out.println(Tens + "Tens");
IDENTIFYING THE PLACE VALUE OF
THE DIGIT
//calculating the value of ones
result3 = num%10;
Ones = result3/1;
System.out.println(Ones + "Ones");
Input.close();
return ;
}
}
OUTPUT:
Enter number:6785
There are:
6Thousands
7Hundreds
8Tens
5Ones
COMBINATION OF LOGICAL AND
RELATIONAL OPERATORS
OUTPUT:

More Related Content

PPTX
Files streams..
PDF
Java Week4(B) Notepad
PDF
Tutorial - 16 : How to pass parameters from one script to another by CallScri...
PDF
GTAC 2014: What lurks in test suites?
PDF
Correctness and Performance of Apache Spark SQL
PDF
ECMA Script
DOCX
java program assigment -1
Files streams..
Java Week4(B) Notepad
Tutorial - 16 : How to pass parameters from one script to another by CallScri...
GTAC 2014: What lurks in test suites?
Correctness and Performance of Apache Spark SQL
ECMA Script
java program assigment -1

What's hot (20)

PDF
Introduction to RxJS
DOCX
PPTX
Functional Reactive Programming (FRP): Working with RxJS
PPT
Stack linked list
PDF
PPT
Core java day4
TXT
Example
PDF
An Introduction to Reactive Cocoa
PPTX
Rxandroid
PDF
ReactiveCocoa in Practice
PPTX
Anti patterns
DOC
35787646 system-software-lab-manual
PDF
ReactiveCocoa Goodness - Part I of II
PDF
Learn You a ReactiveCocoa for Great Good
PDF
Reactive cocoa made Simple with Swift
PDF
PPTX
An Introduction to RxJava
PDF
Lucene/Solr 3.1
PPTX
Preprocessor , IOSTREAM Library,IOMANIP Library
PPTX
Method overloading
Introduction to RxJS
Functional Reactive Programming (FRP): Working with RxJS
Stack linked list
Core java day4
Example
An Introduction to Reactive Cocoa
Rxandroid
ReactiveCocoa in Practice
Anti patterns
35787646 system-software-lab-manual
ReactiveCocoa Goodness - Part I of II
Learn You a ReactiveCocoa for Great Good
Reactive cocoa made Simple with Swift
An Introduction to RxJava
Lucene/Solr 3.1
Preprocessor , IOSTREAM Library,IOMANIP Library
Method overloading
Ad

Similar to Test Program - Basic operators (20)

PPTX
02slide_accessible.pptx
PDF
Lec 8 03_sept [compatibility mode]
PPTX
Lecture 3 and 4.pptx
PPT
Java căn bản - Chapter3
PPTX
Ch2 Elementry Programmin as per gtu oop.pptx
PPT
lecture2 (1).ppt variable s and operators
PPTX
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
PPTX
130717666736980000
PPT
9781439035665 ppt ch02
PPTX
Chapter 3.4
PPT
Java™ (OOP) - Chapter 2: "Elementary Programming"
PDF
Java q ref 2018
PPTX
Java chapter 2
PPTX
3- Operators in Java
PDF
Lecture3.pdf
PDF
java basics - keywords, statements data types and arrays
PPTX
Numerical data.
PPT
CSE215_Module_02_Elementary_Programming.ppt
PPTX
02. Data Types and variables
02slide_accessible.pptx
Lec 8 03_sept [compatibility mode]
Lecture 3 and 4.pptx
Java căn bản - Chapter3
Ch2 Elementry Programmin as per gtu oop.pptx
lecture2 (1).ppt variable s and operators
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
130717666736980000
9781439035665 ppt ch02
Chapter 3.4
Java™ (OOP) - Chapter 2: "Elementary Programming"
Java q ref 2018
Java chapter 2
3- Operators in Java
Lecture3.pdf
java basics - keywords, statements data types and arrays
Numerical data.
CSE215_Module_02_Elementary_Programming.ppt
02. Data Types and variables
Ad

More from MLG College of Learning, Inc (20)

PPTX
PPTX
PC111-lesson1.pptx
PPTX
PC LEESOON 6.pptx
PPTX
PC 106 PPT-09.pptx
PPTX
PPTX
PPTX
PPTX
PC 106 Slide no.02
PPTX
PPTX
PPTX
PC 106 Slide 1.pptx
PDF
Db2 characteristics of db ms
PDF

Recently uploaded (20)

PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Cell Types and Its function , kingdom of life
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Pre independence Education in Inndia.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Institutional Correction lecture only . . .
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
TR - Agricultural Crops Production NC III.pdf
VCE English Exam - Section C Student Revision Booklet
Anesthesia in Laparoscopic Surgery in India
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Cell Structure & Organelles in detailed.
Computing-Curriculum for Schools in Ghana
Cell Types and Its function , kingdom of life
Complications of Minimal Access Surgery at WLH
Microbial diseases, their pathogenesis and prophylaxis
Microbial disease of the cardiovascular and lymphatic systems
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
01-Introduction-to-Information-Management.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Pre independence Education in Inndia.pdf
Renaissance Architecture: A Journey from Faith to Humanism
PPH.pptx obstetrics and gynecology in nursing
STATICS OF THE RIGID BODIES Hibbelers.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Institutional Correction lecture only . . .

Test Program - Basic operators

  • 1. TEST PROGRAM TAKEN FROM THE PREVIOUS LESSONS
  • 2. REMINDERS IN CREATING A CLASS Make sure that your class is inside of the scr
  • 3. BASIC OPERATORS AND ESCAPE SEQUENCEimport java.util.*; //notes this called source file public class BasicOperators { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner (System.in); int L = 12; float W = (float) 35.4; float A =0; //find the area of a rectangle A = L * W; System.out.println("The area of rectangle is:" + A); System.out.println("**************************"); //find the speed float distance = 3; // 3km. float time = 2;// 2 hrs. float Speed; Speed = distance / time; System.out.println("The speed is:" + Speed); System.out.println("**************************");
  • 4. CONTINUATION: //calculating my age; example only int birthyear = 1992; int presentyear = 2020; int age; age = presentyear - birthyear; System.out.println("My age is :" + age); System.out.println("***********************"); //calculating of modulus; //calculating of modulus; int V = 7,S = 5, m =0; m = V % S; System.out.println("The remainder oft" + V + "tand " + S + "tist" + m); //note I uisng t escape sequence for tab
  • 5. OUTPUT: The area of rectangle is:424.80002 ************************************************ The speed is:1.5 ************************************************ My age is :28 ************************************************ The remainder of 7 and 5 is 2
  • 6. IDENTIFYING THE PLACE VALUE OF THE DIGIT import java.util.*; public class PlaceValue { public static void main(String arg[]) { Scanner Input = new Scanner (System.in); //Variable Declaration int num,Thousand,Hundreds,Tens,Ones; int result1,result2,result3; System.out.print("Enter number:"); num = Input.nextInt(); System.out.println("There are:"); //calculating the value of thousand Thousand = num/1000; System.out.println(Thousand + "Thousands"); //calculating the value of hundreds result1 = num%1000; Hundreds = result1/100; System.out.println(Hundreds + "Hundreds"); //calculating the value of tens result2 = num%100; Tens = result2/10; System.out.println(Tens + "Tens");
  • 7. IDENTIFYING THE PLACE VALUE OF THE DIGIT //calculating the value of ones result3 = num%10; Ones = result3/1; System.out.println(Ones + "Ones"); Input.close(); return ; } } OUTPUT: Enter number:6785 There are: 6Thousands 7Hundreds 8Tens 5Ones
  • 8. COMBINATION OF LOGICAL AND RELATIONAL OPERATORS OUTPUT: