@nakov/

nested-if-else-conditions-csharp

C#

Example of nested if-else conditions in C#

fork
loading
Files
  • main.cs
  • main.exe

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6936050113499983","path":"main.cs","file":{"path":"main.cs","content":{"asEncoding":{"base64":"dXNpbmcgU3lzdGVtOwoKY2xhc3MgTmVzdGVkQ29uZGl0aW9uc0V4YW1wbGUgewogICAgcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKSB7CiAgICAgICAgdmFyIGEgPSBkZWNpbWFsLlBhcnNlKENvbnNvbGUuUmVhZExpbmUoKSk7CiAgICAgICAgdmFyIGIgPSBkZWNpbWFsLlBhcnNlKENvbnNvbGUuUmVhZExpbmUoKSk7CiAgICAgICAgaWYgKGEgPiAwICYmIGIgPiAwICYmIGEgPD0gMTAwICYmIGIgPD0gMTAwKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKGEgKiBiID49IDUwMDApCiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgkIkxhcmdlIHNpemU6IHthKmJ9Iik7CiAgICAgICAgICAgIGVsc2UgaWYgKGEgKiBiID4gMTAwMCAmJiBhICogYiA8IDUwMDApCiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgkIk1pZGRsZSBzaXplOiB7YSAqIGJ9Iik7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCQiU21hbGwgc2l6ZToge2EgKiBifSIpOwogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCQiSW52YWxpZCBzaXplIChhPXthfSwgYj17Yn0pIik7CiAgICB9Cn0K"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System;

class NestedConditionsExample {
    public static void Main() {
        var a = decimal.Parse(Console.ReadLine());
        var b = decimal.Parse(Console.ReadLine());
        if (a > 0 && b > 0 && a <= 100 && b <= 100)
        {
            if (a * b >= 5000)
                Console.WriteLine($"Large size: {a*b}");
            else if (a * b > 1000 && a * b < 5000)
                Console.WriteLine($"Middle size: {a * b}");
            else
                Console.WriteLine($"Small size: {a * b}");
        }
        else
            Console.WriteLine($"Invalid size (a={a}, b={b})");
    }
}