Ejemplo n.º 1
0
func main() {
	done := false
	for done == false {
		fmt.Println(c.CL+c.B3+"Welcome to Solvr ", c.V, "α 1.0.0")
		fmt.Println(c.B2 + "Select a mode by typing the assosiated key in red")
		u.Spacer(2)
		fmt.Println(c.R+"{add}", c.G, "Basic mathmatics (add, subtract, multiply, devide)")
		fmt.Println(c.R+"{mxb}", c.G, "Slope solver (y=m(x)+b)")
		fmt.Println(c.R+"{soe}", c.G, "Systems of equations (y=m(x)+b, y=m(x)+b)")
		//fmt.Println(c.R+"{alg}", c.G, "Simple algebra (10 + 5x = 6x)")
		//fmt.Println(c.R+"{src}", c.G, "See the github source code (this will launch a webpage in your browser)")
		fmt.Println(c.R+"{fin}", c.G, "Exit program")
		mode, err := i.Prompt(c.M + ">" + c.B)
		u.QuitAtError(err)
		use := strings.ToLower(mode)

		switch use {
		case "add":
			simple.Function()
		case "mxb":
			slope.Function()
		case "soe":
			equ.Function()
		case "alg":
			fmt.Println(c.G + "Not a feature yet")
		case "src":
			fmt.Println(c.G + "Not a feature yet")
		case "fin":
			fmt.Println(c.G + "Ok! Bye!")
			done = true
		default:
			fmt.Println(c.G + "Not a valid statement")
		}

	}
}
Ejemplo n.º 2
0
func Function() {
	fmt.Println(c.CL+c.B3+"Welcome to the System of Equations module", c.V, "β 1.0.0")
	fmt.Println(c.B2 + "Make sure you have a slope and y-intercept for all of the lines.")
	fmt.Println(c.B2 + "If you don't know your decimals, here's a key:")
	fmt.Println(c.G + "1/2 = .5, 1/3 = .333, 1/4 = .25, 1/5 = .2, 1/6 = .167, 1/7 = .143, 1/8 = .125, 1/9 = .111, 1/10 = .1")
	fmt.Println(c.B2+"If you do not have all equation's slope and y-intercept, type", c.R, "no"+c.B2+".")
	fmt.Println(c.G+"If you do, type", c.R, "yes"+c.G+".")
	fmt.Println()
	check, err := i.Prompt(c.M + "> " + c.B)
	u.QuitAtError(err)
	if check == "no" {
		form.Function()
	}
	//defines the first slope
	fmt.Println(c.CL + c.G + "Enter first slope.")
	filler, err := i.Prompt(c.M + "> " + c.B)
	u.QuitAtError(err)
	m1, err := strconv.ParseFloat(filler, 64)
	u.QuitAtError(err)
	//defines the first intercept
	fmt.Println(c.CL + c.G + "Enter first y-intercept.")
	filler, err = i.Prompt(c.M + "> " + c.B)
	u.QuitAtError(err)
	b1, err := strconv.ParseFloat(filler, 64)
	u.QuitAtError(err)
	/*
	* Now to define the second set
	 */
	//defines the second slope
	fmt.Println(c.CL + c.G + "Enter second slope.")
	filler, err = i.Prompt(c.M + "> " + c.B)
	u.QuitAtError(err)
	m2, err := strconv.ParseFloat(filler, 64)
	u.QuitAtError(err)
	//defines the second intercept
	fmt.Println(c.CL + c.G + "Enter second y-intercept.")
	filler, err = i.Prompt(c.M + "> " + c.B)
	u.QuitAtError(err)
	b2, err := strconv.ParseFloat(filler, 64)
	/*
	* At this point, we break and check for paralell & exact same lines
	 */
	if m1 == m2 && b1 != b2 {
		fmt.Println(c.CL + c.G + "The answer is...")
		fmt.Println(c.Y + "No solution, the lines are paralell")
	} else if m1 == m2 && b1 == b2 {
		fmt.Println(c.CL + c.G + "The answer is...")
		fmt.Println(c.Y + "All numbers on either line, they are the same.")
	} else {
		//Now that there isn't a chance of the program running forever or not at all,
		//We put in some user-defined braces for decimals, then guess we shall!
		fmt.Println(c.CL + c.B2 + "up to how many decimal places should we look for the answer?")
		fmt.Println(c.B3 + "WARNING! MORE DECIMAL PLACES WILL MAKE YOUR COMPUTER WORK EXPONENTIALLY HARDER AND TAKE MORE TIME!\nMORE THAN 3 POINTS IS AT YOUR OWN RISK!")
		filler, err = i.Prompt(c.M + "> " + c.B)
		//Now to change this into a .00X format...
		anotherBsFiller, err := strconv.ParseFloat(filler, 64)
		u.QuitAtError(err)
		someBsFiller := anotherBsFiller * -1.0
		const decimalPlace float64 = math.Pow(10, someBsFiller)
		fmt.Println("LINE 118")
		fmt.Println(decimalPlace)
		//The superguess function above is used
		x, y := guessForever(decimalPlace, m1, b1, m2, b2)
		//
		fmt.Println(c.CL + c.G + "The point of interseption is...")
		x32 := strconv.FormatFloat(x, 'E', -1, 32)
		y32 := strconv.FormatFloat(y, 'E', -1, 32)
		fmt.Println(c.Y + "(" + x32 + "," + y32 + ")")
		u.Go(1)
	}

}