$30
CS 278 Lab: Quantified statements
Write a program that does the following. It should take as a user input ten different integers and store
them in a length ten integer array (with no repeated entries). The domain D is the set of entries in this
array.
Recall that if the domain is a finite set of elements {a1, a2, ..., ak}, then:
∀x P(x) ≡ P(a1) ∧ P(a2) ∧ ... ∧ P(ak) and
∃x P(x) ≡ P(a1) ∨ P(a2) ∨ ... ∨ P(ak).
Your program should evaluate the truth/falsity of the following statements with respect to the domain
D. For each statement, it should print the statement label and its truth value.
Statements:
a)
x
( if x<0 then x is odd ).
b)
x
( if x<0 then x is odd ).
c)
x
( x<0 and x is odd ).
d)
x
( if x is divisible by 3 then x is divisible by 5 ).
e)
x
( if x is divisible by 3 then x is divisible by 5 ).
Your program must compute truth-values correctly for all possible inputs.
Example:
An output produced by your program may look like the following (user input is in green):
Please enter 10 different integers: 6 7 -2 3 0 -4 1 5 -6 8
a) is False
b) is True
c) is False
d) is False
e) is True
Note: There is no typo in the sample output. Answer to b) is True. We can take x=6. Then, x<0 is False.
Therefore, statement “if 6<0 then 6 is odd” is True. Similarly, answer to e) is True. We can take x=7.
Then, “x is divisible by 3” is False. Therefore, statement “if 7 is divisible by 3 then 7 is divisible by 5”
is True.
Implementation details:
You may assume that the user input is always correct (that is, the user always enters integers
with no repeated entries). You do not need to check the user input for correctness.
What to submit:
Submit the source code of your program using Canvas.
If you write your program in a programming language other than Java, then submit instructions
on how to compile and run your program on CS machines.