際際滷

際際滷Share a Scribd company logo
Builders & Developers
Workshop
session 2
Prepared & Presented
by
Moatasim Magdy
MSTC-CU15
Agenda
 If condition.
 Operators.
 Steps to make a good program.
 Simple calculator.
 Functions.
 Where we are now & what`s our aim.
 Windows 8 applications.
 Windows phone applications.
 Universal applications.
 Our first universal app.
Shopping problem !
Go and buy me pepsi, If you didn`t find pepsi, buy me juice, if you didn`t find juice
return home and don`t buy any thing.
Shopping problem !
Pseudo code
If ( You find Pepsi)
Buy Pepsi
Else if (You find juice )
Buy juice
Else
Return home
If structure
If ( Condition )
Action ;
Else if ( Condition )
Action ;
Else if ( Condition) )
Action ;
.
.
.
Else
Action ;
Operators in c#
 = , . (Assignment operators).
 > , < , >= , <= , == , != (Comparison operators).
 && , || (logical operators).
AND Operator
 My GPA will be C if my grade is
between 65 AND 75.
 Here all the conditions must be
true.
OR Operator
 Go and buy me pepsi OR cola
 Here only one of the conditions
is enough, one must be true.
GPA program
using System;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
int Grade;
Grade =
int.Parse(System.Console.ReadLine());
if (Grade >= 0 && Grade < 50)
Console.WriteLine("F");
else if (Grade >= 50 && Grade < 65)
Console.WriteLine("D");
else if (Grade >= 65 && Grade < 75)
Console.WriteLine("C");
else if (Grade >= 75 && Grade < 85)
Console.WriteLine("B");
else if (Grade >= 85 && Grade <= 100)
Console.WriteLine("A");
else
Console.WriteLine("Error");
Console.ReadKey();
}
}
}
Steps to make a good program
1.Idea
Simple
Calculator
2.Define your destination
Session two Builders & Developers workshop Microsoft Tech Club Cairo University`15
3.Define Requirements
Loops
Loops
While Loop FOR Loop
While Loop FOR Loop
int x =0;
While (x < 10)
{
Console.WriteLine(x)
;
X++;
}
for ( int x = 0;x < 10 ;
x++)
{
Console.WriteLine(x);
}
Power
static void Main(string[] args)
{
double number;int power;
number = double.Parse(Console.ReadLine());
power = int.Parse(Console.ReadLine());
double x = number;
for (int z = 1; z < power; z++)
{
number *= x;
}
Console.WriteLine(number);
Console.ReadKey();
}
}
Session two Builders & Developers workshop Microsoft Tech Club Cairo University`15
Session two Builders & Developers workshop Microsoft Tech Club Cairo University`15
 /moatasim.magdy
 /moatasimmagdy
 mo3tasim_94@hotmail.com
Session two Builders & Developers workshop Microsoft Tech Club Cairo University`15

More Related Content

Session two Builders & Developers workshop Microsoft Tech Club Cairo University`15

  • 1. Builders & Developers Workshop session 2 Prepared & Presented by Moatasim Magdy MSTC-CU15
  • 2. Agenda If condition. Operators. Steps to make a good program. Simple calculator. Functions. Where we are now & what`s our aim. Windows 8 applications. Windows phone applications. Universal applications. Our first universal app.
  • 3. Shopping problem ! Go and buy me pepsi, If you didn`t find pepsi, buy me juice, if you didn`t find juice return home and don`t buy any thing.
  • 4. Shopping problem ! Pseudo code If ( You find Pepsi) Buy Pepsi Else if (You find juice ) Buy juice Else Return home
  • 5. If structure If ( Condition ) Action ; Else if ( Condition ) Action ; Else if ( Condition) ) Action ; . . . Else Action ;
  • 6. Operators in c# = , . (Assignment operators). > , < , >= , <= , == , != (Comparison operators). && , || (logical operators).
  • 7. AND Operator My GPA will be C if my grade is between 65 AND 75. Here all the conditions must be true.
  • 8. OR Operator Go and buy me pepsi OR cola Here only one of the conditions is enough, one must be true.
  • 9. GPA program using System; namespace ConsoleApplication8 { class Program { static void Main(string[] args) { int Grade; Grade = int.Parse(System.Console.ReadLine()); if (Grade >= 0 && Grade < 50) Console.WriteLine("F"); else if (Grade >= 50 && Grade < 65) Console.WriteLine("D"); else if (Grade >= 65 && Grade < 75) Console.WriteLine("C"); else if (Grade >= 75 && Grade < 85) Console.WriteLine("B"); else if (Grade >= 85 && Grade <= 100) Console.WriteLine("A"); else Console.WriteLine("Error"); Console.ReadKey(); } } }
  • 10. Steps to make a good program
  • 16. Loops
  • 17. Loops
  • 19. While Loop FOR Loop int x =0; While (x < 10) { Console.WriteLine(x) ; X++; } for ( int x = 0;x < 10 ; x++) { Console.WriteLine(x); }
  • 20. Power static void Main(string[] args) { double number;int power; number = double.Parse(Console.ReadLine()); power = int.Parse(Console.ReadLine()); double x = number; for (int z = 1; z < power; z++) { number *= x; } Console.WriteLine(number); Console.ReadKey(); } }
  • 23. /moatasim.magdy /moatasimmagdy mo3tasim_94@hotmail.com