Question: Study the code below and determine which option represents the correct if - then - else statement for the given ternary operator: Console.Write (

Study the code below and determine which option represents the correct if-then-else statement for the given ternary operator:
Console.Write("What is the temperature today? ");
string input = Console.ReadLine();
double temp = double.Parse(input);
string result =(temp >30)?"It is hot today" : "It is not so hot today";
Console.WriteLine(result);
a.
// Prompt the user to enter a temperature
Console.Write("What is the temperature today? ");
string input = Console.ReadLine();
double temp = double.Parse(input);
string result = string.Empty;
if (temp >30)
{
result ="It is hot today";
}
else
{
result ="It is not so hot today";
}
Console.WriteLine(result);
b.
Console.Write("What is the temperature today? ");
string input = Console.ReadLine();
double temp = double.Parse(input);
string result = string.Empty;
if (temp >30)
result ="It is hot today";
if (temp <30)
result ="It is not so hot today";
Console.WriteLine(result);
c.
// Prompt the user to enter a temperature
Console.Write("What is the temperature today? ");
string input = Console.ReadLine();
double temp = double.Parse(input);
string result = string.Empty;
if (temp >30)
result ="It is hot today";
if (temp =<30)
result ="It is not so hot today";
Console.WriteLine(result);
d.
// Prompt the user to enter a temperature
Console.Write("What is the temperature today? ");
string input = Console.ReadLine();
double temp = double.Parse(input);
if (temp >30)
string result ="It is hot today";
if (temp <=30)
string result ="It is not so hot today";
Console.WriteLine(result);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!