Thursday, August 1, 2019

Biggest Number Using Functions in Go

Write a program that will ask the user four numbers and then the program will check and determine which of the given number has the biggest value and display the results on the screen. The program also asks the user if the user would like to repeat running the program or not using functions.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Sample Program Output


Program Listing

/* four.go
Authors
Mr. Jake R. Pomperada
Mr. Rollyn M.  Moises
Mr. Sunday Vince V. Latergo
Date : July 31, 2019  Wednesday  2:53 AM
 */
package main

import (
"fmt"
"strings"
)


func Ask4confirm() bool {
var s string

fmt.Printf("\tDo you want to continue? (Y/N): ")
_, err := fmt.Scan(&s)
if err != nil {
panic(err)
}

s = strings.TrimSpace(s)
s = strings.ToLower(s)

if s == "y"  {
start()

} else {
fmt.Print("\n")
fmt.Print("\tEnd of Program")
fmt.Print("\n")

}
return false

}


func start() {

var a, b, c,d int

fmt.Print("\n")
fmt.Print("\tBiggest Number Using Functions")
fmt.Print("\n\n")
fmt.Print("\tGive any four numbers : ")
fmt.Scan(&a, &b, &c, &d)

check_four(a,b,c,d)

isConfirmed := Ask4confirm()
if isConfirmed {
start()
}
}

func check_four(a,b,c,d int) int {
var biggest int
if a > b && a > c && a > d {
biggest = a
} else if b > c && b >d {
biggest = b
} else if c > d {
biggest = c
} else {
biggest = d
}
fmt.Print("\n")
fmt.Print("\tThe Biggest in Four Number is ", biggest)
fmt.Print("\n\n")

return 0
}


func main() {
start()
}




No comments:

Post a Comment