goko36
Yeni Üye
- Katılım
- 2 May 2020
- Mesajlar
- 1
- En iyi yanıt
- 0
- Puanları
- 1
- Yaş
- 26
- Konum
- istanbul
- Ad Soyad
- göktuğ sevgil
öncelikle vba for excelde yeniyim. Kullanıcının yazdığı verilerle kübik denklemi çözecek bir kod yazmam gerekiyor fakat ne yaparsam yapayım çözüme ulaşamadım. acaba yaklaşımım mı yanlış? yardımcı olabilecek varmı. kod satırlarımı aşağıya kopyalıyorum.
PHP:
Option Explicit
Function Q1(a, b) As Double
Q1 = (a ^ 2 - 3 * b) / 9
End Function
Function R1(a, b, c) As Double
R1 = (2 * a ^ 3 - a * 9 * b + 27 * c) / 54
End Function
Sub question3()
Dim a, b, c, pi, Ac, Th, root1, root2, root3 As Double
MsgBox "This program solves quadratic equation in the form of x3+ax2+bx+c=0"
a = InputBox("Please enter the value of a")
b = InputBox("Please enter the value of b")
c = InputBox("Please enter the value of c")
pi = WorksheetFunction.pi()
Ac = WorksheetFunction.Acos(Th)
Th = (R1(a, b, c) / Q1(a, b) ^ 1 / 3)
If ((R1(a, b, c) ^ 2) < (Q1(a, b) ^ 3)) Then
root1 = (-2 * Sqr(Q1(a, b)) * Cos(Ac / 3 - a / 3))
root2 = (-2 * Sqr(Q1(a, b)) * Cos(Ac + 2 * pi) / 3 - a / 3)
root3 = (-2 * Sqr(Q1(a, b)) * Cos(Ac - 2 * pi) / 3 - a / 3)
MsgBox "First root of the equation is : " & root1 & vbNewLine & vbNewLine & "Second root of the equation is : " & root2 & vbNewLine & vbNewLine & "Third root of the equation is : " & root3
Else
MsgBox "Your entries do not meet the required condition"
End If
End Sub
Ekli dosyalar
Moderatör tarafında düzenlendi: