package Practice;
import javax.swing.JOptionPane;
public class Oefening1{
public static void main(String[] args) {
char[] dader = {'A','A','C','A','G','G','C','T'};
char[] controle = new char[dader.length];
for(int x = 0;x < controle.length;x++){
controle[x] = leesletter();
}
int percentage = vergelijkDNA(dader,controle);
JOptionPane.showMessageDialog(null, "Overeenkomst " + percentage + " %",
"Uitvoer",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
public static char leesletter(){
char houder;
String temp = JOptionPane.showInputDialog(null,"Voer de letter A G C T in","CSI I",
JOptionPane.INFORMATION_MESSAGE);
houder = temp.charAt(0); //De eerste letter van de String wordt ingegeven.
if(houder == 'A'){
return houder;
}
else if(houder == 'G'){
return houder;
}
else if(houder == 'C'){
return houder;
}
else if(houder == 'T'){
return houder;
}
else {
return 'F';
}
}
public static int vergelijkDNA(char[] a,char[] b){
double dperc = 0;
double tel = 0;
int aantal = a.length;
for(int x = 0;x < a.length; x++){
if(a[x] == b[x]){
tel++;
}
}
dperc = tel/aantal;
System.out.println(tel + " " + aantal);
System.out.println(dperc);
double tperc = dperc * 100;
int perc = (int)tperc;
return perc;
}
}