Do I need to look into switch statements or somthing else or am I missing the point?
I guess I just have to make a function right !??
So I wish to know if I modified this code for user input to select two atom’s
atom_A & atom_B , could I write the code so that the if statements take the user request atom’s and look at the appropriate array slices for those atom’s and result the negativity atom bond type,
I have if statement’s for the 3 atomic bond types.
otherwise I have to write if else code for every atom pair in my array slice var block,
I know I lonly have hydrogen and oxygen at the moment.
but I would like to have other atom’s as well…
package main
import (
"fmt"
)
var (
// Atom Slice Array's [Electron's,Proton's,Neutron's,ElectroNegativity]
atom_H = []float32 {1,1,0,2.20}
atom_O = []float32 {8,8,8,3.44}
// Molecule Element Count [In Order OF Element's]
molecule_H2O = []string {"2","1"}
electronegativity_difference float32 = 0
)
func main() {
fmt.Printf("Hydrogen:\nE:%v P:%v N:%v EN:%v\n",atom_H[0],atom_H[1],atom_H[2],atom_H[3])
fmt.Printf("Oxygen:\nE:%v P:%v N:%v EN:%v\n",atom_O[0],atom_O[1],atom_O[2],atom_O[3])
fmt.Println("H20:",molecule_H2O[0:]) //Println function good for printing 'string slices'.
goto atomic_bond
atomic_bond:
if (atom_O[3] - atom_H[3]) > 0 {electronegativity_difference = (atom_O[3] - atom_H[3])
} else {electronegativity_difference = (atom_H[3] - atom_O[3])}
if electronegativity_difference >= 0.0 && electronegativity_difference <0.3 {fmt.Println("nonpolar-covalent bond")
} else if electronegativity_difference >=0.3 && electronegativity_difference <1.4 {fmt.Println("polar-covalent bond")
} else if electronegativity_difference >1.4 {fmt.Println("ionic bond")}
fmt.Println()
}