Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROVIDED THE CODES OF THE QUESTION ABOVE FOR C# CHANGE THEM TO JAVA . class Program { static void Main(string[] args) { int s1 =

image text in transcribed

PROVIDED THE CODES OF THE QUESTION ABOVE FOR C# CHANGE THEM TO JAVA .

class Program

{

static void Main(string[] args)

{

int s1 = 1;

int s2 = 0;

int t1 = 0;

int t2 = 1;

int q;

int t;

int s;

int r;

Console.WriteLine("Please enter mumber to be divided");

int r1 = int.Parse(Console.ReadLine());

Console.WriteLine("Please enter the dividend");

int r2 = int.Parse(Console.ReadLine());

//Console.WriteLine("Quotient: {0}, R1: {1}, R2: {2}, R: {3}, S1: {4}, S2: {5}, S6: {6}, T1: {7}, T2: {8}, T: {9}", q, r1, r2, r, s1, s2, s, t1, t2, t);

DataTable dt = new DataTable();

dt.Columns.Add("q");

dt.Columns.Add("r1");

dt.Columns.Add("r2");

dt.Columns.Add("r");

dt.Columns.Add("s1");

dt.Columns.Add("s2");

dt.Columns.Add("s");

dt.Columns.Add("t1");

dt.Columns.Add("t2");

dt.Columns.Add("t");

while (r2 > 0)

{

q = r1 / r2;

r = r1 - q * r2;

s = s1 - q * s2;

t = t1 - q * t2;

dt.Rows.Add(q, r1, r2, r, s1, s2, s, t1, t2, t);

Console.WriteLine("Quotient: {0}, R1: {1}, R2: {2}, R: {3}, S1: {4}, S2: {5}, S: {6}, T1: {7}, T2: {8}, T: {9}",q,r1,r2,r,s1,s2,s,t1,t2,t);

r1 = r2; r2 = r;

s1 = s2; s2 = s;

t1 = t2; t2 = t;

}

}

}

Implement the extended Euclidean algorithm to find the greatest common divisor of any two positive integers a and b, as well as values for s and t such that sx a +txb = gcd(a,b). It should also provide an accurate response if the user enters a zero. It should implement the pseudocode provided in the text. It should allow the user to enter two integers a and b. Your program should output the intermediate values of q, r, r1, r2, 5, 51, 52, t, t1, and t2 for each step. It should return the greatest common divisor and values fors and t. Challenge task: Provide error checking to confirm that the input is not negative. This is an individual assignment. Upload the following 1) a file of the code 2) screenshots of output for at least 4 pairs of inputs. Implement the extended Euclidean algorithm to find the greatest common divisor of any two positive integers a and b, as well as values for s and t such that sx a +txb = gcd(a,b). It should also provide an accurate response if the user enters a zero. It should implement the pseudocode provided in the text. It should allow the user to enter two integers a and b. Your program should output the intermediate values of q, r, r1, r2, 5, 51, 52, t, t1, and t2 for each step. It should return the greatest common divisor and values fors and t. Challenge task: Provide error checking to confirm that the input is not negative. This is an individual assignment. Upload the following 1) a file of the code 2) screenshots of output for at least 4 pairs of inputs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

What are the major parts of an email message?

Answered: 1 week ago