Download presentation
Presentation is loading. Please wait.
1
If – Case Programs --------------------- 206CSC Arwa © 2008
2
P oints: --------------------- 206CSC Arwa © 2008 IF-else Statements. Select Cases.
3
E xample: --------------------- 206CSC Arwa © 2008 Write a program which allows the user to perform simple tasks on a calculator. Read two numbers and symbol of operation ( ‘+’ or ‘-’ or ‘ * ’ or ‘/’ ), then display the result as a fellow: Enter the first number :4 Then the second:3 Now..,choose the operation that u want (+, -, *, / ):* The result of chosen operation is:12
4
E xample: --------------------- 206CSC Arwa © 2008 Module Module1 Sub Main() Dim x1,x2,r As Double Dim o as string Console.WriteLine(" Enter the first number : ") x1 = Console.ReadLine() Console.WriteLine(" Then the second:") x2 = Console.ReadLine() Console.WriteLine(" Now..,choose the operation that u want (+, -, *, / )") o= Console.ReadLine()
5
E xample: --------------------- 206CSC Arwa © 2008 Module Module1 Sub Main() Select case o case “+” r=x1 + x2 case “-” r=x1 - x2 case “*” r=x1 * x2 case “/” r=x1 / x2 End Select Console.WriteLine(" The result of chosen operation is:{0}“,r) Console.ReadLine() End Sub End Module
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.