Write a program that recommends whether you should bring an umbrella to school. Your program should ask the user to enter the probability for rain in today’s weather forecast. If the probability is greater than 30% then output “Bring your umbrella today”. Otherwise, output “Leave your umbrella at home today”. Test your program using the values 50 and 20.
using System;
namespace App
{
class Program
{
static void Main(string[] args){
//ask the user to enter the probability for rain in today’s weather forecast.
Console.Write("Enter the probability for rain in today's weather forecast: ");
int probability = int.Parse(Console.ReadLine());
//If the probability is greater than 30% then output "Bring your umbrella today".
if (probability > 30)
{
Console.WriteLine("Bring your umbrella today.");
}
else
{
//Otherwise, output "Leave your umbrella at home today".
Console.WriteLine("Leave your umbrella at home today.");
}
Console.ReadLine();
}
}
}
Comments
Leave a comment