Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Advanced Programming Examples. using System; class Test { static void Main( string[] args ) { int a = 7; int b = 3; int c = 5; int d = 9; Console.WriteLine(!(d.

Similar presentations


Presentation on theme: "1 Advanced Programming Examples. using System; class Test { static void Main( string[] args ) { int a = 7; int b = 3; int c = 5; int d = 9; Console.WriteLine(!(d."— Presentation transcript:

1 1 Advanced Programming Examples

2 using System; class Test { static void Main( string[] args ) { int a = 7; int b = 3; int c = 5; int d = 9; Console.WriteLine(!(d == a) || (a < b+c) && (d-c <= b)); } 2

3 A factory has some workers and it divides its workers into three skill levels. Unskilled workers receive L.E. 8.15 per hour, semiskilled workers receive L.E. 12.55 an hour, and skilled workers L.E. 18.60 an hour. Write a program to calculate the worker’s weekly pay formatted to two decimal places. Your program input should consist of the hours worked and a skill level indicator for the worker. Then the wage should be displayed.

4 for (int N = 1; N < 10; N++) { if ( N % 2 == 0) MessageBox.Show (“X”); else if ( N % 3 == 0) MessageBox.Show (“Y”); else MessageBox.Show (“Z”); } MessageBox.Show(“End”);

5 Write a C program that reads in 30 integer numbers and then print out their sum and average

6 int a = 5; int b = 10; a = a + 5; { int a; a = 20; b = b + 5 ; } MessageBox.Show(a+ " " + b) } 6

7 Write a program that reads 100 integer numbers, determines how many positive and negative values have been read, and computes the average of the input values.

8 The value that printed is int delta = 0, x = 3; if (x / 2 = = 1) delta = delta + x; x - -; if (x / 2 = = 0) delta = delta + x; x - -; MessageBox.Show(delta);

9 int p, d=4, a=20; if ((d==4) && (a>24)) { p=d+a; MessageBox.Show( “ Low Risk \n ” );} else { p=a-d; MessageBox.Show( “ Low Risk \n ” );} MessageBox.Show( “ the p is = “+ p); Trace

10 int I = 12, J = 0; while ( I > 8) { I = I -1; J = J + I; } MessageBox.Show( I+”\t”+J);

11 Trace length = 10; count = 2; while ( count < 5 ) { if ( length >= 10 ) length = length – 2; else length = length * count; count++; } MessageBox.Show( “ The length is ” + length);

12 int x=2, y=2, k=1; do { y = y * x; MessageBox.Show(“k = k+ “y=“+ y); y = y – k; MessageBox.Show(“k = k+ “y=“+ y); k = k + 1; } while (k < 4);

13 String a = "alfred"; String b = "fred"; b = "al" + b; if (a == b) a = "fred"; else b = "fred"; 13


Download ppt "1 Advanced Programming Examples. using System; class Test { static void Main( string[] args ) { int a = 7; int b = 3; int c = 5; int d = 9; Console.WriteLine(!(d."

Similar presentations


Ads by Google