Ejemplo n.º 1
0
func findAorB() {
	//This the the part where we declare A&B
	fmt.Println(c.CL + c.B1 + "What is point x1?")
	x1 := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is point y1?")
	y1 := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is point x2?")
	x2 := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is point y2?")
	y2 := i.DoubleInput(c.M + ">>> " + c.B)
	//Now we math. c1 is the answer and all the others are just to show work
	x := x2 + x1
	y := y2 + y1
	xSq := x / 2
	ySq := y / 2
	//Now we show work
	fmt.Printf("%s%sThe formula is: ((x2+x1)/2),((y2+y1)/2)\n", c.CL, c.B01)
	fmt.Printf("%sLet's do this:\n((%s%f%s+%s%f%s)/2),((%s%f%s+%s%f%s)/2)\n",
		c.B01, c.B1, x2, c.B01, c.B1, x1, c.B01, c.B1, y2, c.B01, c.B1, y1, c.B01)
	fmt.Printf("%s((%s%f%s)/2),(%s%f%s)/2)\n", c.B01, c.B1, x, c.B01, c.B1, y, c.B01)
	fmt.Printf("%s(%s%f%s,%s%f%s)\n", c.B01, c.B1, xSq, c.B01, c.B1, ySq, c.B01)
	s.Spacer(1)
	fmt.Printf("%sthe midpoint is (%f,%f).\n", c.O, xSq, ySq)
	s.Go(1)
}
Ejemplo n.º 2
0
func findC() {
	//This the the part where we declare A&B
	fmt.Println(c.CL + c.B1 + "What is point x1?")
	x1 := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is point y1?")
	y1 := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is point x2?")
	x2 := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is point y2?")
	y2 := i.DoubleInput(c.M + ">>> " + c.B)
	//Now we math. c1 is the answer and all the others are just to show work
	x := x2 - x1
	y := y2 - y1
	xSq := x * x
	ySq := y * y
	c2 := xSq + ySq
	c1 := math.Sqrt(c2)
	//Now we show work
	fmt.Printf("%s%sThe formula is: sqrt((x2-x1)^2+(y2-y1)^2)\n", c.CL, c.B01)
	fmt.Printf("%sLet's do this:\nsqrt((%s%f%s-%s%f%s)^2+(%s%f%s-%s%f%s)^2\n",
		c.B01, c.B1, x2, c.B01, c.B1, x1, c.B01, c.B1, y2, c.B01, c.B1, y1, c.B01)
	fmt.Printf("%ssqrt((%s%f%s)^2+(%s%f%s)^2)\n", c.B01, c.B1, x, c.B01, c.B1, y, c.B01)
	fmt.Printf("%ssqrt(%s%f%s+%s%f%s)\n", c.B01, c.B1, xSq, c.B01, c.B1, ySq, c.B01)
	fmt.Printf("%ssqrt(%s%f%s)\n", c.B01, c.B1, c2, c.B01)
	s.Spacer(1)
	fmt.Printf("%sSquared distance is %f\n", c.O, c1)
	fmt.Printf("%sUnsquared distance is %f\n", c.O, c2)
	s.Go(1)
}
Ejemplo n.º 3
0
func findAorB() {
	//This the the part where we declare A&B
	fmt.Println(c.CL + c.B1 + "What is side C's size?")
	c1 := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is side B's size?")
	b := i.DoubleInput(c.M + ">>> " + c.B)
	//Now we math.
	c2 := c1 * c1
	b2 := b * b
	a2 := c2 - b2
	a := math.Sqrt(a2)
	//Defining a squared, b squared and c squared
	//along with solving for c (I used c1 as to prevent the possibility of problems with c, colors)

	//Now we show work
	fmt.Printf("%s%s%f (c) squared is %f, %f (b) squared is %f.\n", c.CL, c.B1, c1, c2, b, b2)
	s.Spacer(1)
	fmt.Printf("%s%f%s - %s%f%s = %s%f%s.\n", c.B1, c2, c.B01, c.B1, b2, c.B01, c.B1, a2, c.B01)
	fmt.Printf("%sThe square root of %s%f%s is %s%f%s.\n", c.B01, c.B1, a2, c.B01, c.B1, a, c.B1)
	s.Spacer(2)
	fmt.Printf("%sa = %f\n", c.O, a)
	s.Go(1)
}
Ejemplo n.º 4
0
func findC() {
	//This the the part where we declare A&B
	fmt.Println(c.CL + c.B1 + "What is side A's size?")
	a := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is side B's size?")
	b := i.DoubleInput(c.M + ">>> " + c.B)
	//Now we math.
	a2 := a * a
	b2 := b * b
	c2 := a2 + b2
	c1 := math.Sqrt(c2)
	//Defining a squared, b squared and c squared
	//along with solving for c (I used c1 as to prevent the possibility of problems with c, colors)

	//Now we show work
	fmt.Printf("%s%s%f%s (a) squared is %s%f%s, %s%f%s (b) squared is %s%f%s.\n", c.CL, c.B1, a, c.B01, c.B1, a2, c.B01, c.B1, b, c.B01, c.B1, b2, c.B01)
	s.Spacer(1)
	fmt.Printf("%s%f%s + %s%f%s = %s%f%s.\n", c.B1, a2, c.B01, c.B1, b2, c.B01, c.B1, c2, c.B01)
	fmt.Printf("%sThe square root of %s%f%s is %s%f%s.\n", c.B01, c.B1, c2, c.B01, c.B1, c1, c.B01)
	s.Spacer(2)
	fmt.Printf("%sc = %f\n", c.O, c1)
	s.Go(1)
}
Ejemplo n.º 5
0
func FindDiscriminant() {
	//This the the part where we declare A&B
	fmt.Println(c.CL + c.B1 + "What is a?")
	a := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is b?")
	b := i.DoubleInput(c.M + ">>> " + c.B)
	fmt.Println(c.CL + c.B1 + "What is c?")
	cNumber := i.DoubleInput(c.M + ">>> " + c.B)
	//\\
	discAns := ((b * b) - (4 * a * cNumber))
	bb := b * b
	ac := a * cNumber
	ac4 := ac * 4
	//\\
	fmt.Printf("%s%s(%s%f%s)^2-4*%s%f%s*%s%f%s\n", c.CL, c.B01, c.B1, b, c.B01, c.B1, a, c.B01, c.B1, cNumber, c.B01)
	fmt.Printf("%s%f%s-4*%s%f%s*%s%f%s\n", c.B1, bb, c.B01, c.B1, a, c.B01, c.B1, cNumber, c.B01)
	fmt.Printf("%s%f%s-4*%s%f%s\n", c.B1, bb, c.B01, c.B1, ac, c.B01)
	fmt.Printf("%s%f%s-%s%f%s\n", c.B1, bb, c.B01, c.B1, ac4, c.B01)
	s.Spacer(1)
	fmt.Printf("%sThe discriminate is %f. ", c.O, discAns)
	solveQuad := 1
	if discAns > 0 {
		fmt.Printf("Meaning there are two solutions.\n")
	} else if discAns == 0 {
		fmt.Printf("Meaning there is one solution.\n")
	} else if discAns < 0 {
		fmt.Printf("Meaning there are no solutions.\n")
		solveQuad = 0
	} else {
		fmt.Println("ERROR. NOPE. BYE!")
		os.Exit(-1)
	}
	s.Go(1)
	//////////////////////////
	//Now to solve quadratic//
	//////////////////////////

	//Quadratic Formula: x=(-b ± sqrt(b^2-4ac))/2a

	if solveQuad == 1 {
		desc := math.Sqrt(discAns)
		negB := (-1 * b)
		firstTop := (negB + desc)
		secondTop := (negB - desc)
		quadA := (firstTop / (2 * a))
		quadB := (secondTop / (2 * a))
		a2 := (2 * a)
		//Show work
		fmt.Printf("%s%sx=(%s%f%s±%s%f%s)/2(%s%f%s)\n", c.CL, c.B01, c.B1, negB, c.B01, c.B1, desc, c.B01, c.B1, a, c.B01)
		fmt.Printf("%sx=(%s%f%s±%s%f%s)/%s%f%s\n", c.B01, c.B1, negB, c.B01, c.B1, desc, c.B01, c.B1, a2, c.B01)
		s.Spacer(1)
		fmt.Printf("%sx=(%s%f%s)/%s%f%s\n", c.B01, c.B1, firstTop, c.B01, c.B1, a2, c.B01)
		fmt.Printf("%sx=(%s%f%s)/%s%f%s\n", c.B01, c.B1, secondTop, c.B01, c.B1, a2, c.B01)
		s.Spacer(2)
		//Show answer
		if quadB == quadA {
			fmt.Printf("%sThe solution to this quadratic is %f\n", c.O, quadA)
		} else {
			fmt.Printf("%sThe solutions to this quadratic are %f and %f\n", c.O, quadA, quadB)
		}
		s.Go(1)
	}
}