Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Republic of the Philippines

CAVITE STATE UNIVERSITY


Bacoor City Campus
SHIV, Molino VI, City of Bacoor

DEPARTMENT OF COMPUTER STUDIES


DCIT 50: OBJECT ORIENTED PROGRAMMING

ACTIVITY 01

DIRECTION:

• Create a Java Program based on the instruction below. Using notepad, create
your codes and save it with filename: Lastname-Firstname-Activity02.java
• Attach your .java file here or upload a screenshot or image of your code.
• Write a Java program that accepts two integer values from the user and return the
larger values. However if the two values are the same, return 0 and return the
smaller value if the two values have the same remainder when divided by 6.
Example:
Input the first number : 12
Input the second number: 13
Result: 13

Input the first number : 12


Input the second number: 12
Result: 0

Input the first number : 6


Input the second number: 18
Result: 6

RUBRICS FOR GRADING

Category Description
Program compiles and contains no evidence of
Syntax
misunderstanding or misinterpreting the syntax of the
(20pts)
language.
Correctness Program produces correct answers or appropriate results
(30pts) for all inputs tested.
Completeness Program shows evidence of excellent case analysis, and
(20pts) all possible cases are handled appropriately.
Logic Program logic is correct, with no known boundary errors,
(30pts) and no redundant or contradictory conditions.
Republic of the Philippines
CAVITE STATE UNIVERSITY
Bacoor City Campus
SHIV, Molino VI, City of Bacoor

DEPARTMENT OF COMPUTER STUDIES


DCIT 50: OBJECT ORIENTED PROGRAMMING
Activity Sheet
1st Semester, A.Y. 2022-2023

Name: Gabion, Jon David S. Date: 01/03/2023


Course/Yr&Section: BSIT 2-5 Score:

ANSWER

import java.util.*;
public class Activity1 {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Input the first number : ");
int a = in.nextInt();
System.out.print("Input the second number: ");
int b = in.nextInt();
System.out.println("Result: "+result(a, b));
}
public static int result(int x, int y)
{
if(x == y)
return 0;
if(x % 6 == y % 6)
return (x < y) ? x : y;
return (x > y) ? x : y;
}
}

You might also like