コード例 #1
0
ファイル: main.go プロジェクト: whitman-colm/go-1
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
}
コード例 #2
0
ファイル: module.go プロジェクト: whitman-colm/calculator
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
}
コード例 #3
0
ファイル: main.go プロジェクト: whitman-colm/go-projects
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")
		}

	}
}
コード例 #4
0
ファイル: module.go プロジェクト: whitman-colm/calculator
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
	}
}