Insert tab, always the way to go if shut in a short hand bind
Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle) and released in 1995 as a core component of Sun Microsystems' Java platform
1995 the answer
Answer:
if (pH<7.0){
neutral=0;
base=0;
acid=1;
}
else if (pH>7.0){
neutral=0;
base=1;
acid=0;
}
else if (pH==7.0){
neutral=1;
base=0;
acid=0;
}
Explanation:
As required by the question, if and else statements have been used to test the value of the pH and assign the apropriate values to the variables neutral, base and acid.
The code snippet below can be used to prompt the user to enter values for pH
<em>import java.util.Scanner;</em>
<em>public class pHTest {</em>
<em> public static void main(String[] args) {</em>
<em> Scanner scr = new Scanner(System.in);</em>
<em> System.out.println("Enter a value for the pH");</em>
<em> int neutral, base, acid;</em>
<em> double pH = scr.nextDouble();</em>
<em> if (pH<7.0){</em>
<em> neutral=0;</em>
<em> base=0;</em>
<em> acid=1;</em>
<em> }</em>
<em> else if (pH>7.0){</em>
<em> neutral=0;</em>
<em> base=1;</em>
<em> acid=0;</em>
<em> }</em>
<em> else if (pH==7.0){</em>
<em> neutral=1;</em>
<em> base=0;</em>
<em> acid=0;</em>
<em> }</em>
<em>} }</em>
Answer:
Check the explanation
Explanation:
CODE:
static int findEvenQueue(Queue<Integer> numbers)
{
//loop runs till the queue has atleast one element
while(numbers.size() > 0)
{
//Checking the head of the queue whether it is even
int temp = numbers.peek();
if(temp % 2 == 0)
{
//if the head is even then return it
return temp;
}
else
{
//else remove the number at head
int removed = numbers.poll();
}
}
//if no even number present in the Queue then return -1
return -1;
}