Skip to content

Instantly share code, notes, and snippets.

@ganeshbabuNN
Last active April 8, 2024 14:03
Show Gist options
  • Save ganeshbabuNN/5e8b1e659de36ae09a822fae39b3fcf3 to your computer and use it in GitHub Desktop.
Save ganeshbabuNN/5e8b1e659de36ae09a822fae39b3fcf3 to your computer and use it in GitHub Desktop.
EPGPSD2024_Precendence Order of Logical Operators
/*
Description
Assume that you have built a lie detector which detects the level of chemicals X and Y.
If the sum of the amounts of X and Y is greater than 30, then the person is telling the truth.
Write Java code to take in the values of X and Y and detect whether the person is telling the truth or not. If the person is telling the truth, display "The statement said by the person is true". If the person is lying then display "The statement said by the person is false".
Sample input:
12
23
Sample output:
The statement said by the person is true
*/
import java.util.*;
public class Source {
public static void main(String[] args) {
int x,y,z;
Scanner input =new Scanner(System.in);
x=input.nextInt();
y=input.nextInt();
z=x+y;
if(z>30){
System.out.println("The statement said by the person is true");
}else{
System.out.println("The statement said by the person is false");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment