Ask Question
13 April, 19:22

Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the bool variables neutral, base, and acid: a. false, false, true if pH is less than 7 b. false, true, false if pH is greater than 7 c. true, false, false if pH is equal to 7

+3
Answers (1)
  1. 13 April, 19:44
    0
    public class PhTester {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("What is the pH Value");

    double pH = in. nextDouble ();

    boolean neutral, base, acid;

    if (pH<7.0)

    {

    neutral=false;

    base=false;

    acid=true;

    }

    else if (pH>7.0)

    {

    neutral=false;

    base=true;

    acid=false;

    }

    else if (pH==7.0)

    {

    neutral=true;

    base=false;

    acid=false;

    }

    }

    }

    Explanation:

    A complete java code is given above:

    1. the variables neutral, acid, base are declared as booleans

    2. Scanner class is used to request the user to enter a value for the pH

    3. If/else statements are used to assign values to the variables
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the bool variables neutral, ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers