In C# ArgumentException is an existing class that derives from Exception; you use it when one or more of a method’s arguments do not fall within an expected range.

Write the application SwimmingWaterTemperature containing a variable that can hold a temperature expressed in degrees Fahrenheit. Within the class, create a method that accepts a parameter for a water temperature and returns true or false, indicating whether the water temperature is between 70 and 85 degrees and thus comfortable for swimming. If the temperature is not between 32 and 212 (the freezing and boiling points of water), it is invalid, and the method should throw an ArgumentException.

In the Main() method, continuously prompt the user for data temperature, pass it to the method, and then display the following messages indicating whether the temperature is comfortable, not comfortable, or invalid:

X degrees is comfortable for swimming.
X degrees is not comfortable for swimming.
Value does not fall within the expected range.

Enter the value 999 to quit the program.

40
999

Output

Results
40 degrees is not comfortable for swimming.
Test CaseIncomplete

Invalid swimming temperature entered
Input

31
999

Output

Results
Value does not fall within the expected range.
Enter another temperature or 999 to quit
0.00
out of
10.00

Program runs until user quits

0 out of 1 checks passed. Review the results below for more details.
Checks
Test CaseIncomplete

Can enter more than one temperature
Input

77
69
999

Output

Results
77 degrees is comfortable for swimming.
Enter another temperature or 999 to quit
69 degrees is not comfortable for swimming.
Enter another temperature or 999 to quit

Recommended Answers

All 3 Replies

Please help us to help you :)

Can you please show us the code you have so far, where you are stuck, what’s confusing you, and how we can help you to successfully complete your homework assignment. Much thanks!

commented: using System; public class SwimmingWaterTemperatur { public static void Main() { while(true){ Console.Write("\nPlease enter the water temperatur +0

Please post your code here ...

Screen_Shot_2022-09-13_at_8.43.35_PM.png

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.