0% found this document useful (0 votes)
10 views4 pages

Java Activity

Uploaded by

Vincent valendez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Java Activity

Uploaded by

Vincent valendez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Activity 1: Assignment Operator

import [Link];
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner([Link]);
[Link]("Enter the first number: ");
int n1= [Link]();
[Link]("Enter the second number: ");
int n2 = [Link]();
[Link]("Sum: " +(n1+=n2));
[Link]("Difference: " +(n1-=n2));
[Link]("Product: " +(n1*=n2));
[Link]("Quotient:" +(n1/=n2));

}
Activity 2:Logical Operator

import [Link];
public class VotingEligibility {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter age: ");
int age = [Link]();
[Link]("Eligible to vote: " + (age >=
18));
[Link]("Senior citizen: " + (age >=
65));
[Link]("Eligible to vote and a senior
citizen: " + ((age >= 18)&&(age >= 65)));
}
}
Avtivity 3: Math Functions

import [Link];

public class Main {


public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);

[Link]("Enter decimal number: ");


double num = [Link]();

double ceilValue = [Link](num);


double floorValue = [Link](num);
int roundedValue = (int) [Link](num);
[Link]("Ceil Value: " + (3.0));
[Link]("Floor Value: " + (2.0));
[Link]("Rounded Value: " + (3.0));
}
}
Activity 4: String Functions

import [Link];
public class FourthActivity{
public static void main(String[] args) {
Scanner input = new Scanner([Link]);
[Link]("Enter first name: ");
String fname = [Link]();
[Link]("Enter second name: ");
String lname = [Link]();
[Link]([Link]());
[Link](", ");
[Link]([Link]());
[Link]("I\'m a \\\"BSIS\"\\ student");
}
}

You might also like