Melton
Melton
CC#
Created by Melton on 5/1/2024 in #help
if statements with more than once condition
Hi, I'm struggling a bit with figuring out how to add ranges as conditions in my if/else if statements. Rather than having conditions being above, below, or equal to X, I want to be able to find whether or not a statement fits a very specific condition. How would you proceed with this problem? This is where I get stuck:
c#
int a = 10;
int b = 10;
int c = 10;
int d = 10;

int x = a + b + c + d;

Random random = new Random();
int numberFinder = random.Next(0, x);

string 1 = "The number is 10 or lower";
string 2 = "The number is between 11 and 20";
string 3 = "The number is between 21 and 30";
string 4 = "The number is 31 or higher";

if ( numberFinder <= a )
{
Console.Writeline(1);
}
else if ( numberFinder ????????????????????
c#
int a = 10;
int b = 10;
int c = 10;
int d = 10;

int x = a + b + c + d;

Random random = new Random();
int numberFinder = random.Next(0, x);

string 1 = "The number is 10 or lower";
string 2 = "The number is between 11 and 20";
string 3 = "The number is between 21 and 30";
string 4 = "The number is 31 or higher";

if ( numberFinder <= a )
{
Console.Writeline(1);
}
else if ( numberFinder ????????????????????
13 replies