Showing posts with label Gender Checker Using If Statement in Golang. Show all posts
Showing posts with label Gender Checker Using If Statement in Golang. Show all posts

Tuesday, July 30, 2019

Gender Checker Using If Statement in Golang


Write a program using an if statement that will ask the person's name and gender. The user can type either letter F for Female or M for Male. The program will greet the person by making the person's name display in upper case format and display what is the gender of the person's on the screen.

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

/* gender.go
Authors
Mr. Jake R. Pomperada
Mr. Rollyn M.  Moises
Mr. Sunday Vince V. Latergo
Date : July 28, 2019  Sunday   5:42 AM
 */

package main

import (
"bufio"
"fmt"
"os"
"strings"
"unicode"
)

func main() {
consoleReader := bufio.NewReader(os.Stdin)
fmt.Print("\n")
fmt.Print("\tGender Checker Using If Statement")
fmt.Print("\n\n")
fmt.Print("\tWhat is your name?   : ")
user_name, _ := consoleReader.ReadString('\n')
fmt.Print("\n")
fmt.Print("\tSelect M - Male  F - Female")
fmt.Print("\n\n")
fmt.Print("\tWhat is your gender? : ")
gender, err := consoleReader.ReadByte()
name_display := strings.ToUpper(user_name)
if err != nil {
panic(err)
}
gender = byte(unicode.ToLower(rune(gender)))

fmt.Print("\n")

if (gender == 'f') {
fmt.Println("\tHello", name_display)
fmt.Printf("\tYou are certified FEMALE.")
}
if (gender == 'm') {
fmt.Println("\tHello", name_display)
fmt.Printf("\tYou are certified MALE.")
}

if (gender != 'f'  && gender  != 'm') {
fmt.Printf("\tInvalid Gender Value. Try Again.")
}
fmt.Print("\n\n")
fmt.Print("\tEnd of Program")
fmt.Print("\n")
}