What is the current state of water?
★☆☆In physics, a state of matter is one of the distinct forms in which matter can exist. Four states of matter are observable in everyday life: solid, liquid, gas, and plasma. Many intermediate states are known to exist, such as liquid crystal, and some states only exist under extreme conditions, such as Bose–Einstein condensates (in extreme cold), neutron-degenerate matter (in extreme density), and quark–gluon plasma (at extremely high energy).
Write a program that outputs liquid state, solid state or gaseous state depending on the temperature of water in °C.
Remember to add a comment before a subprogram or selection statement to explain its purpose.
water_state so that it:Enter the temperature in °C:
20
The water is in a liquid state.
Enter the temperature in °C:
-8
The water is in a solid state.
Enter the temperature in °C:
106.89
The water is in a gaseous state.
// States of water problem
using System;
class Submission
{
---
// -------------------------
// Subprograms
// -------------------------
// Return the state of water
---
static string water_state(double centigrade)
{
---
// Less than or equal to 0°
if (centigrade <= 0)
{
---
return "solid";
---
}
---
// Less than 100° but greater than 0°
else if (centigrade < 100)
{
---
return "liquid";
---
}
---
// 100° or above.
else
{
---
return "gaseous";
---
}
---
}
---
// -------------------------
// Main program
// -------------------------
public static void Main(string[] args)
{
---
Console.WriteLine("Enter the temperature in °C:");
double temperature = Convert.ToDouble(Console.ReadLine());
---
string state = water_state(temperature);
---
Console.WriteLine($"The water is in a {state} state.");
---
}
---
}