|
|
|
|
|
پاسخ تمرینات فصل 12 مبانی کامپیوتر سوال 1 فصل 12 Private Sub cmdrun_Click() سوال 3 صفحه 135: كد: Private Sub Command1_Click() Dim a As Integer, b As Integer a = Val(InputBox("Enter number a :")) b = Val(InputBox("Enter number b :")) If b <> 0 Then Form1.Print a \ b Else Form1.Print "not defined" End Sub
سوال 4 صفحه 135: كد: Dim yy0 As Integer, mm0 As Integer, dd0 As Integer Dim yy As Integer, mm As Integer, dd As Integer Dim y As Integer, m As Integer, d As Integer Private Sub Command1_Click() yy0 = Val(Text1.Text) mm0 = Val(Text2.Text) dd0 = Val(Text3.Text) dd = Day(Date) mm = Month(Date) yy = Year(Date) Print yy, mm, dd If dd < dd0 Then mm = mm - 1 dd = dd + 30 End If d = dd - dd0 If mm < mm0 Then yy = yy - 1 mm = mm + 12 End If m = mm - mm0 If yy >= yy0 Then y = yy - yy0 Else MsgBox "not valid" Exit Sub End If Print yy0, mm0, dd0 Print "sal="; y, "mah="; m, "rooz"; d End Sub
سوال 5 صفحه 135: كد: Dim a As Integer, b As Integer, c As Integer, delta As Integer Dim x1 As Single, x2 As Single Private Sub Command1_Click() a = Val(Text1.Text) b = Val(Text2.Text) c = Val(Text3.Text) delta = b ^ 2 - 4 * a * c If delta >= 0 Then x1 = (-b + Sqr(delta)) / (2 * a) x2 = (-b - Sqr(delta)) / (2 * a) MsgBox "x1=" + Str(x1) + " " + "x2=" + Str(x2) Else MsgBox "Not Root" End If End Sub
سوال6صفحه 135: كد: Dim citynam As String, cnam1 As String, cnam2 As String Dim max As Integer, min As Integer, dama As Integer Private Sub Command1_Click() citynam = InputBox("Enter a city name : ") dama = Val(InputBox("enter dama : ")) cnam1 = citynam cnam2 = citynam max = dama min = dama For i = 2 To 10 citynam = InputBox("Enter a city name : ") dama = Val(InputBox("enter dama : ")) If min > dama Then cnam1 = citynam min = dama End If If max < dama Then cnam2 = citynam max = dama End If Next Form1.Print "shahr="; cnam1, "minimum dama="; min Form1.Print "shahr="; cnam2, "maximum dama="; max End Sub
سوال 7صفحه 135: كد: Dim salary As Long Private Sub Command1_Click() salary = Val(InputBox("Enter hoghogh : ")) If salary <= 200000 Then MsgBox salary Exit Sub End If If salary <= 800000 Then MsgBox salary - (salary - 200000) * 0.1 Exit Sub Else MsgBox salary - (salary - 800000) * 0.12 Exit Sub End If End Sub
سوال 8صفحه 135: كد: Dim n As Integer Private Sub Command1_Click() n = Val(InputBox("Enter number n : ")) Y1 = n Mod 10 n = n \ 10 Y2 = n Mod 10 n = n \ 10 y3 = n Mod 10 y4 = n \ 10 Form1.Print Y1 * 1000 + Y2 * 100 + y3 * 10 + y4 End Sub
سوال 9صفحه 135: كد: Dim k As Integer, c As Integer Private Sub Command1_Click() k = 12 c = 0 Do While k < 100 c = c + 1 Form1.Print k k = k + 3 Loop Print "tedad="; c End Sub
سوال 10صفحه 135: كد: Dim no As Byte Private Sub Command1_Click() no = Val(InputBox("Enter a day of week : ")) Select Case no Case 1 MsgBox "Shanba" Case 2 MsgBox "yek Shanba" Case 3 MsgBox "dow Shanba" Case 4 MsgBox "seh Shanba" Case 5 MsgBox "chohar Shanba" Case 6 MsgBox "panj Shanba" Case 7 MsgBox "jomah" Case Else MsgBox "not valid" End Select End Sub
پاسخ فعالیت های فصل 12 مبانی کامپیوتر نقل قول: جواب فعالیت1
كد: a =val(inputbox("Enter a :")) b =val(inputbox("Enter b :")) c =val(inputbox("Enter c :")) if (a+b>c) and (a+c>b) and (b+c>a) then msgbox "This is triangle" else "This is not triangle"
نقل قول: جواب فعالیت2
كد: nam = inputbox("Enter name :") n = val(inputbox("Enter grade : ") if n>=0 and n<=20 then select case n case 18 to 20 grade="A" case 15 to 18 grade="B" case 12 to 15 grade="C" case 10 to 12 grade="D" case else grade="E" End select End if Msgbox "you got degree "+grade
نقل قول: جواب فعالیت3
كد: n=val(inputbox("Enter number of lesson :")) sum =0 for i=1 to n num = val(inputbox("Enter grade of lesson :")) sum=sum+num next i msgbox "average is "+str(sum/n)
نقل قول: جواب فعالیت4
كد: price=val(inputbox("Enter a price : ")) sum=price while price<>0 price=val(inputbox("Enter a price : ")) sum=sum+price wend msgbox "Sum of price is "+str(sum)
|
||
|
+
نوشته شده در پنجشنبه هفدهم اردیبهشت 1388ساعت 8:38 توسط پوران ولادتی
|
|
||