Chapter Two Java Sample Code 1 1. Object Creation
Chapter Two Java Sample Code 1 1. Object Creation
Student states
Id of student
Name of student
Mark of student
Student behavior
A method which calculate the grade
A method to display the name and grade of the student
Constructor member
Parameterize constructor
To initialize (accept) students information’s student id, name and mark
Note:-use this keyword to access member of class with in the class
7. Control statements
A) If statement
Question 1: write a program that take two number from the user and display the first
number is greater than, less than, or equal to, the second number
Question 2: write a program that take a number from the user and check the number
greater than zero, less than zero, or equal to zero
Question 3: write a program that take a number from the user and find the number is
even or odd
Question 4: write a program that take the final mark from the user and convert a final
grade in a scale of 0 to 100 to a letter grade (i.e. 90 to 100corrosponds A,80 to 89 is
B,70 to 79 is C ,60 to 69 is D and less than 60 is F)
Question 5:write a program that takes a number from the user and check a number is
less than 10,if so display a message below 10.if not check a number whether less than
60 or nor ,if so display a message below 60