티스토리 뷰
// // // 11/10/2017 // AT1.4 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace AT1._4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnStart_Click(object sender, EventArgs e) { // get input from the Form and // then parse as integers. // CAUTION no error trapping int one = int.Parse(tbInputOne.Text); int two = int.Parse(tbInputTwo.Text); clearOutput(); runCal(one, two); } private void clearOutput() { // clear the output text boxes tbOneA.Clear(); tbOneB.Clear(); tbTwoA.Clear(); tbTwoB.Clear(); tbThreeA.Clear(); tbThreeB.Clear(); tbFinalA.Clear(); tbFinalB.Clear(); } private void runCal(int a, int b) { // IF statement number One if (a > b) { int temp = b; b = a; a = temp; tbOneA.Text = a.ToString(); tbOneB.Text = b.ToString(); } // IF statement number two if ((Math.Cos(a)) < 0 && (Math.Cos(b) > 0)) { a = 1; b = 3; tbTwoA.Text = a.ToString(); tbTwoB.Text = b.ToString(); } int x = (a + b) / 2; // IF statement number three if (Math.Cos(x) > 0) { a = x; tbThreeA.Text = a.ToString(); } else { b = x; tbThreeB.Text = b.ToString(); } // Final values of a and b tbFinalA.Text = a.ToString(); tbFinalB.Text = b.ToString(); } } } /* Step One Input / Expected Output / Actual Results 5,2 / 1,2 / 1,2 8,6 / 7,8 / 7,8 2,5 / 1,2 / 1,2 4,4 / 4,4 / 1,2 7,5 / 6,7 / 1,2 4,8 / 6,8 / 1,2 9,7 / 7,8 / 7,8 */ /* Change line 54 if ((Math.Cos(a)) < 0 || (Math.Cos(b) > 0)) to if ((Math.Cos(a)) < 0 && (Math.Cos(b) > 0)) */ /* in Cos(x), when x is 1, 5, 6 or 7, it's value is positive (cos(x)>0) when x is 2, 3, 4, 8, 9 or 10, it's value is nagative (cos(x)<0) 5,2 / 2,5 / -, + only thing that has to work second if statement 8,6 / 6,8 / +, - 2,5 / 2,5 / -, + 4,4 / 4,4 / -, - 7,5 / 5,7 / +, + 4,8 / 4,8 / -, - 9,7 / 7,9 / +, - */
idle / input 7, 5 / input 5, 2
'AU Study > TAFE Assessment' 카테고리의 다른 글
C sharp programming AT 1.1 (0) | 2017.10.25 |
---|---|
C sharp programming AT 1.2 (0) | 2017.10.25 |
Javascript Portfolio (0) | 2017.10.24 |
C sharp programming AT 2 (1) | 2017.10.22 |
C sharp programming AT 1.3 (0) | 2017.09.29 |
댓글