java ass 2
java ass 2
10/03/25
class Arthematicoperator {
public static void main(String[] args) {
int a = 999;
int b = 888;
int sum = a+b;
System.out.println(sum);
System.out.println(a-b);
System.out.println(a*b);
System.out.println(a/b);
System.out.println(a%b);
}
}
O/P:
class Assignmentoperator {
public static void main(String[] args) {
int a = 80;
int b = 90;
System.out.println(a+=50);
System.out.println(b-=32);
System.out.println(a*=26);
System.out.println(a/=20);
System.out.println(a%=92);
}
}
O/P:
class Relationaloperator {
public static void main(String[] args) {
int x = 1000;
int y = 999;
System.out.println(x<y);
System.out.println(x<=500);
System.out.println("===========");
System.out.println(y>100);
System.out.println(y>=200);
System.out.println("===========");
System.out.println(x==y);
System.out.println(x!=y);
System.out.println(x==150);
System.out.println(x==1000);
System.out.println(x!=190);
System.out.println(y!=999);
System.out.println("===========");
}
}
O/P:
4 . Write a java program print name, age, height, gender of Tom and Jerry?
class Tom {
public static void main(String[] args) {
System.out.println(nameTom + " " + ageTom + " " + heightTom + " " + genderTom + " |
"
+ nameJerry + " " + ageJerry + " " + heightJerry + " " + genderJerry);
}
}
O/P:
ASSIGNMENT -2
12/03/25
1.Get input for Variable Mark. If mark > 35 print pass. Else Print fail.
2.Get input for Variable Income. If Income is greater than 7000 scholarship is available Else
not eligible for scholarship.
3.Get input for a number and check whether it is divisible by both 3 and 5 or not. If yes then
print, the number is divisible by 3 and 5 print the number is not divisible by 3 and 5 How to
find the number is divisible by 3 or Not?
int n = 8;
if (n % 2 == 0)
System.out.println("Even number");
else
System.out.println("Odd number");
5.What is the score of the game? -if the score is less than 50,print "You need to improve." -if
the score is between 50 and 70 (inclusive), print "Good job!" -if the score is greater than
70,print "Excellent Performance!".
{
System.out.println("You need to improve.");
}
else if (score <= 70)
{
System.out.println("Good job!");
}
else
{
System.out.println("Excellent Performance!");
}
6.What is the color of the traffic Light? -If the answer is "red," print "Stop." -If the answer is
"yellow" print "Get Ready". -If the answer is "green," print "Go."
10.(Simple if)?
if (gender == 'M')
{
System.out.println("Male");
}
if (g == 'M') System.out.println("Male");
else if (g == 'F') System.out.println("Female");
else System.out.println("Other");
else System.out.println("Zero.");
15.WJP to display Student Result Note:- 80-100 -> Passed with Distinction 60-79 -> First Class
35-59 -> Pass 0-34 -> Fail others -> not valid
if (x != y) {
if (x > y) System.out.println(x + " is greater.");
if (p > q) {
if (p > r) System.out.println(p + " is the largest.");
} else {
if (q > r) System.out.println(q + " is the largest.");
}
18.WJP for Gmail Login (Nested-if)
String username = "user", password = "pass123";
if (username.equals("user")) {
O/P:-