Professional Documents
Culture Documents
Gabion JonDavid Activity01
Gabion JonDavid Activity01
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
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
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;
}
}