43.5k views
5 votes
In chemistry, the pH of an aqueous solution is a measure of its acidity. The pH scale ranges from 0 to 14, inclusive. A solution with a pH of 7 is said to be neutral, a solution with a pH greater than 7 is basic, and a solution with a pH less than 7 is acidic. Write a script that will prompt the user for the pH of a solution, and will print whether it is neutral, basic, or acidic. If the user enters an invalid pH, an error message will be printed.

User Geedew
by
3.5k points

1 Answer

3 votes

Answer:

See Explaination

Step-by-step explanation:

clear all;

clc;

fprintf('Enter the pH value of the solution=');

pH=input('');

if pH == 7

fprintf('The solution is neutral.');

elseif pH >= 0 && pH < 7

fprintf('The solution is basic.');

elseif pH > 7 && pH <= 14

fprintf('The solution is acidic.');

else

fprintf('Error. The entered pH value is invalid.');

end

User Lunar Mushrooms
by
3.2k points