static void Main.docx - private void button1_Click(object sender EvenArgs e int num1 int num2 int sum num1 = Convert.ToInt32(textBox1.Text num2 =

static void Main.docx - private void button1_Click(object...

This preview shows page 1 - 2 out of 2 pages.

private void button1_Click(object sender, EvenArgs e) { int num1; int num2; int sum; num1 = Convert.ToInt32(textBox1.Text); num2 = Convert.ToInt32(textBox2.Text); sum = num1 + num2; label3.Text = “Sum is “ + sum; } static void Main() { const int HIGH = 10, LOW = 5; string numberString; int number; Write(“Enter an integer ”); numberString = ReadLine(); number = Convert.ToInt32(numberString); if(number > LOW) if(number < HIGH) WriteLine(“{0} is between {1} and {2}”, number, LOW, HIGH); } static void Main() { const int HIGH = 10; string numberString; int number; Write(“Enter an integer ”); numberString = ReadLine(); number = Convert.ToInt32(numberString); if(number > HIGH) WriteLine(“{0} is not greater than {1}”, number, HIGH); } // using the && operator If(age >= 0 && age < 120) WriteLine(“Age is valid”); // using nested ifs If(age >= 0) If(age < 120) WriteLine(“Age is valid”); // using the || operator If(age < 0 || age > 120) WriteLine(Age is not valid”); // using nested ifs If(age < 0) WriteLine(“Age is not valid); else if(age > 120) WriteLine(“Age is not valid”); static void Main() { int age = 10; char rating = ‘R’; const int CHILD_AGE = 12 const int SENIOR_AGE = 65; WriteLine(“When age is {0} and rating is {1}”, age, rating); if((age <= CHILD_AGE || age >= SENIOR_AGE) && rating == ‘G’) WriteLine(“Discount applies”); else WriteLine(“Full price”); } if(year == 1) WriteLine(“Freshman”); else if(year == 2) WriteLine(“Sophomore”); Else If(year ==3) WriteLine(“Junior”); else if(year == 4) WriteLine(“Senior”); else WriteLine(“Invalid year”); If(saleAmount >= 1000) commisionRate = 0.08; else if(saleAmount >= 500) commissionRate = 0.06; else commissionRate = 0.05;
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Spring '10
  • NEWBY

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes