For loop ① fence length ② square brick Area ③ Judge Leap year common year

Source: Internet
Author: User

static void Main (string[] args)
{

Const double PI = 3.14;

const int bar_unit_price = 25;

const int brick_unit_price = 85;

Input

int A, B;

Console.Write ("Please enter the pool radius:");

string S1 = Console.ReadLine ();

A = Convert.ToInt32 (S1);

Console.Write ("Please enter the square radius:");

String s2 = Console.ReadLine ();

b = Convert.ToInt32 (s2);

Operation

Double L = 2 * PI * A; Find the perimeter of the pool

Double area1 = PI * A * a;//the area of the pool.

Double AREA2 = PI * b * b;//total area.

Double area = area2-area1;//Square size

Double barprice = l * bar_unit_price; Total cost of guardrail

Double Brickprice = area * brick_unit_price;//square cost.

Output

Console.WriteLine ("The length of the guardrail is" + L + "meters, the total area of the square brick is" + areas + "square meters, the total cost is" + (Barprice + brickprice) + "Yuan");

}

}
}

The second question determines the case of the root of a two-time equation.

static void Main (string[] args)

{int A, b, C;             Input Console.Write ("Please enter factor A:");

A = Convert.ToInt32 (Console.ReadLine ());

Console.Write ("Please enter factor B:");

b = Convert.ToInt32 (Console.ReadLine ());

Console.Write ("Please input factor C:");

c = Convert.ToInt32 (Console.ReadLine ());

Operation output

if (a = = 0)

{

Console.WriteLine ("Not a two-dimensional equation");

}

Else

{

int d = b * b-4 * a * C;

if (d > 0)

{

Console.WriteLine ("Two Unequal real roots");

}

else if (d = = 0)

{

Console.WriteLine ("Two Equal real Roots");

}

Else

{

Console.WriteLine ("No real Roots");

}

}

}

}

}

The third question, enter a year to determine whether it is leap years or common year.

static void CCC (string[] args)

{

int year;

Input

Console.Write ("Please enter a year:");

Year = Convert.ToInt32 (Console.ReadLine ());

Operation

Divisible by 400, or divisible by 4, but not divisible by 100.

If ((year% 400 = = 0) | | (year% 4 = = 0 && Year% 100! = 0))

{

Console.WriteLine ("is a leap year");

} else

{

Console.WriteLine ("is common year");

}

}

}

}

For loop ① fence length ② square brick Area ③ Judge Leap year common year

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.