Ask Question
7 June, 22:47

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: false, false, true if pH is less than 7 false, true, false if pH is greater than 7 true, false, false if pH is equal to 7

+1
Answers (1)
  1. 8 June, 01:55
    0
    Following are the if/else statement

    if (pH < 7) / / if ph is less then 7

    {

    neutral = 0; / / false

    base = 0; / / false

    acid = 1; / / true

    }

    else if (pH > 7) / / if ph is greater then 7

    {

    neutral = 0; / / false

    base = 1; / / true

    acid = 0; / / false

    }

    else / / if ph equal to 7

    {

    neutral = 1; / / true

    base = 0; / / false

    acid = 0; / / false

    }

    Explanation:

    Following are the description of statement

    In this neutral, base, and acid are the boolean variable. We have to check the three condition. If ph is less then 7 then we have to initialized the neutral = 0, base = 0 and acid = 1 with the boolean value. If ph is greater then 7 then we have to initialized the neutral = 0, base = 1 and acid = 0 with the boolean value. If ph is equal to 7 then we have to initialized the neutral = 1, base = 0 and acid = 0 with the boolean value.
Know the Answer?
Not Sure About the Answer?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers