Exemple #1
0
func PointSlope() {
	fmt.Print(c.CL)
	strx1, err := i.Prompt(c.G + "Enter x1 point\n" + c.B + ">" + c.M)
	u.QuitAtError(err)
	stry1, err := i.Prompt(c.G + "Enter y1 point\n" + c.B + ">" + c.M)
	u.QuitAtError(err)
	strm, err := i.Prompt(c.G + "Enter slope\n" + c.B + ">" + c.M)
	u.QuitAtError(err)
	//all inputs now provided, to be converted.
	x1, err := strconv.ParseFloat(strx1, 64)
	u.QuitAtError(err)
	y1, err := strconv.ParseFloat(stry1, 64)
	u.QuitAtError(err)
	m, err := strconv.ParseFloat(strm, 64)
	u.QuitAtError(err)
	//all data points provided and converted, now to math-a-tise.
	fmt.Println(c.CL, c.G+"The formula is")
	fmt.Println("y = m(x) + b")
	u.Spacer(3)
	//to find "b"
	fmt.Println(y1, " = ", m, "(", x1, ") + b")
	filler := x1 * m
	//multiplies x1 and m to filler.
	u.Spacer(1)
	fmt.Println(y1, " = ", filler, " + b")
	fmt.Println("-", filler, "---------------|")
	//Shows subtraction
	u.Spacer(1)
	b := y1 - filler
	fmt.Println(c.B2+"b =  ", b)
	u.Spacer(3)
	fmt.Println(c.B3+"y = ", m, "(x) + ", b)
	u.Go(1)
	//prints out completed statment, ends function
}
Exemple #2
0
func SrQuestion(context string, question string, cAns string, worth float32) float32 {
	var score float32 = worth
	var done string = "false"
	for done == "false" {
		fmt.Println(c.CL)
		fmt.Println(c.G + context)
		u.Spacer(1)
		fmt.Println(c.R + question)
		u.Spacer(3)
		answer, _ := i.Prompt(c.B + ">" + c.M)
		response := s.ToLower(answer)
		answer = s.TrimSpace(response)
		response = answer

		if response == cAns {
			fmt.Println(c.G + "Correct! :D")
			//return score
			done = "true"
		} else {
			fmt.Println(c.G + "No... try again...")
			filler := score - (.1 * worth)
			score = filler
			u.Go(1)
		}
		//return score
	}
	return score
}
Exemple #3
0
func Function() {
	done := false
	for done == false {
		fmt.Println(c.G + "Select function")
		fmt.Println(c.R + "add" + c.G + ", add.")
		fmt.Println(c.R + "sub" + c.G + ", subtract.")
		fmt.Println(c.R + "mlt" + c.G + ", multiply.")
		fmt.Println(c.R + "dev" + c.G + ", devide.")
		fmt.Println(c.R + "fin" + c.G + ", when you are done.")
		fmt.Println()
		use, _ := i.Prompt(c.B + ">" + c.M)

		if use == "add" {
			add()
		} else if use == "sub" {
			sub()
		} else if use == "mlt" {
			mlt()
		} else if use == "dev" {
			dev()
		} else if use == "fin" {
			fmt.Println(c.G + "Ok! bye!")
			done = true
		} else {
			fmt.Println(c.Y + "That's not a valid argument")
		}
	}
}
Exemple #4
0
func dev() {
	num1, _ := i.Prompt(c.G + "Enter number 1\n" + c.B + ">" + c.M)
	n1, err := strconv.ParseFloat(num1, 64)
	if err != nil {
		fmt.Println(c.Y + "Well &?$@... :-/")
		fmt.Println(err)
		os.Exit(-1)
	}
	fmt.Println()
	num2, _ := i.Prompt(c.G + "Enter number 2\n" + c.B + ">" + c.M)
	n2, err := strconv.ParseFloat(num2, 64)
	if err != nil {
		fmt.Println(c.Y + "Well &?$@... :-/")
		fmt.Println(err)
		os.Exit(-1)
	}
	fmt.Println()
	fmt.Println()
	ans := n1 / n2
	fmt.Printf("Total: %v\n", ans)
}
Exemple #5
0
func Go(testfor int) {
	fmt.Println()
	if testfor == 0 {
		fmt.Println(c.CL)
	} else if testfor == 1 {
		fmt.Println()
		fmt.Println()
		fmt.Println()
	}
	fmt.Println(c.G + "Press enter to continue")
	i.Prompt(c.B + "" + c.M)
	fmt.Println(c.CL)
}
Exemple #6
0
func main() {
	fmt.Println(c.CL)
	fmt.Println(c.G + "How many dice?")
	resp, err := i.Prompt(c.B + ">" + c.M)
	if err != nil {
		s.ErrRpt(err)
	}
	time, err := strconv.Atoi(resp, 32)
	if err != nil {
		s.ErrRpt(err)
	}
	s.Go(0)

}
Exemple #7
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")
		}

	}
}
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)
	}

}
Exemple #9
0
func TwoPoints() {
	fmt.Print(c.CL)
	strx1, err := i.Prompt(c.G + "Enter x1 point\n" + c.B + ">" + c.M)
	//assigns a command-line input to strx1.
	//i.Prompt returns a string "strx1" and an error "err"
	u.QuitAtError(err)
	//Tests if there is an error in the input, and halts the program before it crashes
	stry1, err := i.Prompt(c.G + "Enter y1 point\n" + c.B + ">" + c.M)
	u.QuitAtError(err)
	strx2, err := i.Prompt(c.G + "Enter x2 point\n" + c.B + ">" + c.M)
	u.QuitAtError(err)
	stry2, err := i.Prompt(c.G + "Enter y2 point\n" + c.B + ">" + c.M)
	u.QuitAtError(err)
	//provides the data values. will be converted next 4 lines. "i" pulls from my input function
	//variable err will be processed on-site w/ the input function next version.
	x1, err := strconv.ParseFloat(strx1, 64)
	//Converts strx1 in to a 64-bit float.
	u.QuitAtError(err)
	y1, err := strconv.ParseFloat(stry1, 64)
	u.QuitAtError(err)
	x2, err := strconv.ParseFloat(strx2, 64)
	u.QuitAtError(err)
	y2, err := strconv.ParseFloat(stry2, 64)
	u.QuitAtError(err)
	/*
	*Now for something to actually happen! all variables have been declared!
	 */
	fmt.Println(c.CL + c.G + "The Formula is:" + c.R)
	fmt.Println(c.B1, "y2 - y1")
	fmt.Println(c.B1, "-------")
	fmt.Println(c.B1, "x2 - x1")

	u.Spacer(3)
	//adds three lines blank diffrence.
	fmt.Println(c.R, y2, "-", y1)
	fmt.Println(c.G + "-----------")
	fmt.Println(c.R, x2, "-", x1)
	//Prints out an incomplete equation
	u.Spacer(2)
	num := y2 - y1
	den := x2 - x1
	//the numerator and denominator of the equation.
	fmt.Print(c.R)
	fmt.Println(num)
	fmt.Println(c.G + "-----")
	fmt.Print(c.R)
	fmt.Println(den)
	u.Spacer(2)
	if den == 0 {
		fmt.Println(c.B2, "The slope is undefined")
	} else {
		m := num / den
		fmt.Println(c.B3, "The slope is ", m, ".")
		u.Go(1)
		/////////////////////////////////////
		//adds a break and clears the page.//
		/////////////////////////////////////
		fmt.Println(c.G + "Our y-intercept equation is:")
		fmt.Println(c.B1, "y = m(x) + b"+c.G)

		//all data points provided and converted, now to math-a-tise
		u.Spacer(3)
		//to find "b"
		fmt.Println(y1, " = ", m, "(", x1, ") + b")
		filler := x1 * m
		//multiplies x1 and m to filler
		fmt.Println(y1, " = ", filler, " + b")
		fmt.Println("-(", filler, ")---------------|")
		//Shows subtraction
		u.Spacer(1)
		b := y1 - filler
		fmt.Println(c.B2, "b = ", b)
		u.Spacer(3)
		fmt.Println(c.B3+"y = ", m, "(x) + ", b)
		u.Go(1)
		//prints out completed statment, ends function
	}
}