Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Get the substitution value for P -> Q by: Write a computer program using Java to

ID: 3683946 • Letter: G

Question

Get the substitution value for P -> Q by:

Write a computer program using Java to perform the calculation.

Sequence alignment database:

"PQPP"
"QQQP"
"QQPP"
"QPPP"
"QQQP"

Manual calculation:

We have to compare the character by column, therefore compare PQQQQ, which are the first elements of 5 sequences above.

I need to make a simple program that compares each column and make matrices out of that.

The manual calculation therefore will be:

1st column: P Q Q Q Q

P

Q

P

0

4

Q

6

2nd column: Q Q Q P Q

P

Q

P

0

4

Q

6

3rd column: P Q P P Q

P

Q

P

3

6

Q

1

4th column: P P P P P

P

Q

P

10

0

Q

0

Matrix in total:

P

Q

P

13

14

Q

13


I want to know how to write a Java code to generate the matrix in total..

Thanks!

P

Q

P

0

4

Q

6

Summing the substitution counts We assume the ancestor is one of the observed amino acids, symmetrical matrix one column of a MSA

Explanation / Answer

Solution: To Prove a Java Program to generate the matrix in total

*/

Package javastartinprogs

import java.until.*;

void main()

{

int ch,i,j,m,n,p,q,k,r1,c1,P[10][10],Q[10][10],c[10][10];

clrscr();

printf("************************************");

printf(" MENU");

printf(" **********************************");

printf(" [1]TOTAL OF TWO MATRICES");

printf(" [2]MULTIPLICATION OF TWO MATRICES");

printf(" [0]EXIT");

printf(" **********************************");

printf(" Enter your choice: ");

scanf("%d",&ch);

if(ch<=2 & ch>0)

{

printf("Valid Choice ");

}

switch(ch)

{

case 1:

System.out.println ("Input rows and columns of P matrix:");

scanf("%d%d",&m,&n);

System.out.println ("Input rows and columns of Q matrix:");

scanf("%d%d",&p,&q);

if(n==p)

{

System.out.println("matrices can be calculating ");

System.out.println ("resultant matrix is %d*%d ",m,q);

System.out.println ("Input P matrix ");

read_matrix(a,m,n);

System.out.println ("Input Q matrix ");

/*Function call to read the matrix*/

read_matrix(b,p,q);

/*Function for calculating of two matrices*/

System.out.println (" =====Matrix calculating===== ");

for(i=0;i<m;++i)

    for(j=0;j<q;++j)

    {

      c[i][j]=0;

      for(k=0;k<n;++k)

            c[i][j]=c[i][j]+p[i][j]+Q[i][j]+ Q[i][j]+ Q[i][j]+ Q[i][j];

    }

case 2:

System.out.println ("Input rows and columns of P matrix:");

scanf("%d%d",&m,&n);

System.out.println ("Input rows and columns of Q matrix:");

scanf("%d%d",&p,&q);

if(n==p)

{

System.out.println("matrices can be calculating ");

System.out.println ("resultant matrix is %d*%d ",m,q);

System.out.println ("Input P matrix ");

read_matrix(a,m,n);

System.out.println ("Input Q matrix ");

/*Function call to read the matrix*/

read_matrix(b,p,q);

/*Function for calculating of two matrices*/

System.out.println (" =====Matrix calculating===== ");

for(i=0;i<m;++i)

    for(j=0;j<q;++j)

    {

      c[i][j]=0;

      for(k=0;k<n;++k)

            c[i][j]=c[i][j]+Q[i][j]+ Q[i][j]+ Q[i][j]+P[i][j]+Q[i][j];

    }

case 3:

System.out.println ("Input rows and columns of P matrix:");

scanf("%d%d",&m,&n);

System.out.println ("Input rows and columns of Q matrix:");

scanf("%d%d",&p,&q);

if(n==p)

{

System.out.println("matrices can be calculating ");

System.out.println ("resultant matrix is %d*%d ",m,q);

System.out.println ("Input P matrix ");

read_matrix(a,m,n);

System.out.println ("Input Q matrix ");

/*Function call to read the matrix*/

read_matrix(b,p,q);

/*Function for calculating of two matrices*/

System.out.println (" =====Matrix calculating===== ");

for(i=0;i<m;++i)

    for(j=0;j<q;++j)

    {

      c[i][j]=0;

      for(k=0;k<n;++k)

            c[i][j]=c[i][j]+p[i][j]+Q[i][j]+ P[i][j]+ P[i][j]+ Q[i][j];

    }

case 4:

System.out.println ("Input rows and columns of P matrix:");

scanf("%d%d",&m,&n);

System.out.println ("Input rows and columns of Q matrix:");

scanf("%d%d",&p,&q);

if(n==p)

{

System.out.println("matrices can be calculating ");

System.out.println ("resultant matrix is %d*%d ",m,q);

System.out.println ("Input P matrix ");

read_matrix(a,m,n);

System.out.println ("Input Q matrix ");

/*Function call to read the matrix*/

read_matrix(b,p,q);

/*Function for calculating of two matrices*/

System.out.println (" =====Matrix calculating===== ");

for(i=0;i<m;++i)

    for(j=0;j<q;++j)

    {

      c[i][j]=0;

      for(k=0;k<n;++k)

            c[i][j]=c[i][j]+p[i][j]+P[i][j]+ P[i][j]+ P[i][j]+ P[i][j];

    }

}

case 5:

System.out.println ("Input rows and columns of P & Q Matrix:");

scanf("%d%d",&r1,&c1);

System.out.println ("Enter elements of matrix P: ");

    for(i=0;i<r1;i++)

    {

      for(j=0;j<c1;j++)

      scanf("%d",&a[i][j]);

    }

System.out.println ("Enter elements of matrix Q: ");

    for(i=0;i<r1;i++)

    {

      for(j=0;j<c1;j++)

      scanf("%d",&b[i][j]);

    }

  System.out.println (" =====Matrix TOTAL===== ");

    for(i=0;i<r1;i++)

    {

      for(j=0;j<c1;j++)

      System.out.println ("%5d",P[i][j]+Q[i][j]);

      System.out.println (" ");

    }

break;

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote