(Solved Homework): NEEDS TO BE IN JASMIN so a .j file NOT a .java file…

NEEDS TO BE IN JASMIN so a .j file NOT a .java file

The following jasmin code estimates e using the series:

Don't use plagiarized sources. Get Your Custom Essay on
(Solved Homework): NEEDS TO BE IN JASMIN so a .j file NOT a .java file…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!

Modify this code to estimate  using the series:

The series for  converges very quickly, so the following code only goes for 20 iterations. The series for does not converge quickly. Calculate to at least 100,000 terms once you know your code is working. The following code prints at each iteration of the loop. You probably don’t want to do that for 100000 terms! Take the print out of the loop and move it to after the loop.

; File:      jasmin/examples/Count.j
; Author:    Jonathan Meyer, 10 July 1996
; Purpose:   Counts from 0 to 9, printing out the value
; ————————————————————————-

.class public Eest
.super java/lang/Object

;
; standard initializer
.method public <init>()V
invokenonvirtual java/lang/Object/<init>()V
return
.end method

.method public static main([Ljava/lang/String;)V
; set limits used by this method
.limit locals 16
.limit stack 8

; setup local variables:

;    1 – the PrintStream object held in java.lang.System.out
getstatic java/lang/System/out Ljava/io/PrintStream;
astore_1

;    2 – the counter used in the loop
bipush 20   ; loop counter in 2
istore_2
dconst_1
dconst_1
dstore 4   ; e sum in 4
dconst_1
dstore 6   ; f.p. factorial in 6
dconst_1
dstore 8   ; f.p. n in 8

; now loop 10 times printing out a number

Loop:

; compute 10 – <local variable 2> …
dconst_1
dup2
dstore 8   ; store n
dmul
dstore 6   ; store n!
dconst_1
ddiv
dup2
dstore 4
invokestatic java/lang/String/valueOf(D)Ljava/lang/String;
astore_3
; … and print it
aload_1    ; push the PrintStream object
aload_3    ; push the string we just created – then …
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V

; decrement the counter and loop
iinc 2 -1
ifne Loop

; done
return

.end method

Show transcribed image text0! 1! 2! 3!

Java Code:

//Define a class Eest

public class Eest

{

//Define main

public static void main(String[]args)

{

//Compute value

double val=compute_Pi(100000);

//Display value

System.out.println(val);

}

//Define a method

public static double compute_Pi(int count)

{

//Declare variable

double val=1;

//Loop

for(int i=3;i<count;i+=4)

{

//Compute value

val=val-(1/(double)i)+(1/(double)(i+2));

}

//Return

return val * 4;

}

}

Modified bytecode:

Compiled from “Eest.java”

public class Eest {

public Eest();

Code:

1: invokespecial #1                  // Method java/lang/Object.”<init>”:

()V

4: return

public static void main(java.lang.String[]);

Code:

0: ldc           #2                  // int 100000

2: invokestatic #3                  // Method compute_Pi:(I)D

5: dstore_1

6: getstatic     #4                  // Field java/lang/System.out:Ljava/

io/PrintStream;

10: invokevirtual #5                  // Method java/io/PrintStream.printl

n:(D)V

13: return

public static double compute_Pi(int);

Code:

0: dconst_1

1: dstore_1

2: iconst_3

3: istore_3

6: if_icmpge     29

10: dconst_1

12: i2d

13: ddiv

14: dsub

15: dconst_1

17: iconst_2

19: i2d

20: ddiv

22: dstore_1

23: iinc          3, 4

26: goto          4

30: ldc2_w        #6                  // double 4.0d

33: dmul

34: dreturn

}

Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.