예제 #1
0
func Startup() {
	//the function that's the "main menu" of sorts
	isDone := false
	doWhat := ""
	for isDone == false {
		//for loop so you don't have to come back here each time.
		//and a switch statment to force a responce.
		switch doWhat {
		case "a":
			fmt.Println("PROVIDE FUNCTION")
			doWhat = ""
		case "b":
			fmt.Println("PROVIDE FUNCTION")
			doWhat = ""
		case "d":
			isDone = true
		case "c":
			fmt.Println("PROVIDE FUNCTION")
			doWhat = ""
		default:
			fmt.Println(c.CL + c.B01 + "Quadratics calculator: " + Version)
			s.Spacer(2)
			fmt.Println(c.B1 + "What do you need solved?" + c.X)
			fmt.Println(c.Y + "Enter one of the letters in red:")
			s.Spacer(1)
			fmt.Println(c.R + "{A}" + c.B0 + " [OPTION A]")
			fmt.Println(c.R + "{B}" + c.B0 + " [OPTION B]")
			fmt.Println(c.R + "{C}" + c.B0 + " [OPTION C]")
			fmt.Println(c.R + "{D}" + c.B0 + " Exit system")
			doWhat = i.StringInput(c.M + ">>> " + c.B)

		}
	}
}
예제 #2
0
func Startup() {
	//the function that's the "main menu" of sorts
	isDone := false
	doWhat := ""
	for isDone == false {
		//for loop so you don't have to come back here each time.
		//and a switch statment to force a responce.
		switch doWhat {
		case "a":
			findC()
			doWhat = ""
		case "b":
			findAorB()
			doWhat = ""
		case "c":
			isDone = true
		default:
			fmt.Println(c.CL + c.B01 + "distance and midpoint calculator " + Version)
			s.Spacer(2)
			fmt.Println(c.B1 + "What do you need solved?" + c.X)
			fmt.Println(c.Y + "Enter one of the letters in red:")
			s.Spacer(1)
			fmt.Println(c.R + "{A}" + c.B0 + "  Find distance")
			fmt.Println(c.R + "{B}" + c.B0 + "  Find midpoint")
			fmt.Println(c.R + "{C}" + c.B0 + "  Nothing! Stop talking to me perv!")
			doWhat = i.StringInput(c.M + ">>> " + c.B)
		}
	}
}
예제 #3
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)
}
예제 #4
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)
}
예제 #5
0
func Function() {
	var done bool = false

	fmt.Println(c.CL)
	fmt.Println(c.B3, "Welcome to the Liner Solver by Whitman Huntley.")
	fmt.Println(c.B3, "This calculator supports all rational numbers as float64 datatypes.")
	fmt.Println(c.B3, "This program is text based.To make anything function, enter a keyword and then press enter.")
	u.Spacer(1)
	fmt.Println(c.V, "ERROR CHECK:", c.B00, "Don't mind me, I'm just here to make sure the program \n doesn't break.")
	u.Go(1)

	for done == false {
		fmt.Println(c.CL + c.X + c.G + "What data do you have?")
		fmt.Println(c.R + "a" + c.G + ":  Two pairs of points. (x1, y1), (x2, y2)")
		fmt.Println(c.R + "b" + c.G + ":  The slope and a point. m, (x1, y1)")
		fmt.Println(c.R + "c" + c.G + ":  None, I'd like to leave.")
		mode, err := i.Prompt(c.G + "Select mode using the red key above\n" + c.B + ">" + c.M)
		u.QuitAtError(err)

		switch mode {
		//mode is defined as an input string above.
		case "a", "1":
			s.TwoPoints()
		case "b", "2":
			s.PointSlope()
		case "c", "3":
			fmt.Println(c.Y, "Okey! bye-bye!")
			done = true
		default:
			fmt.Println(c.B, "That statment isn't valid...")
			u.Go(1)
		}
	}
}
예제 #6
0
func mathFuncs() {
	//the only function in this
	isDone := false
	doWhatNow := ""
	for isDone == false {
		//So that you don't have to restart the program each time
		switch doWhatNow {
		case "a":
			ymxb.Function()
			//Calls the ymxb library's startup function. see module for more details.
			doWhatNow = ""
			//We have to reset doWhatNow lest we want the same module on repeat
		case "b":
			tria.Startup()
			doWhatNow = ""
		case "c":
			dist.Startup()
			doWhatNow = ""
		case "d":
			ccs.Startup()
			doWhatNow = ""
		case "e":
			quad.FindDiscriminant()
			doWhatNow = ""
		case "f":
			isDone = true
		default:
			//forces a responce
			fmt.Println(c.CL + c.X + "Functions")
			fmt.Println(c.Y + "Select one of the letters in red")
			s.Spacer(1)
			//adds a line
			fmt.Println(c.R + "{A}" + c.B0 + "  Find a linear slope equation")
			fmt.Println(c.R + "{B}" + c.B0 + "  Find the hypotonuse of a right triangle")
			fmt.Println(c.R + "{C}" + c.B0 + "  Find distance or midpoint")
			fmt.Println(c.R + "{D}" + c.B0 + "  Find volume of cone, cylinder or sphere")
			fmt.Println(c.R + "{E}" + c.B0 + "  Quadratics")
			fmt.Println(c.R + "{F}" + c.B0 + "  Nothing go away")
			s.Spacer(1)
			doWhatNow = i.StringInput(c.B + ">>>" + c.X)
		}
	}
}
예제 #7
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)
}
예제 #8
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)
}
예제 #9
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)
	}
}