Introduction to Programming Analyzing algorithms, methods and show the outputs o
ID: 3849058 • Letter: I
Question
Introduction to Programming Analyzing algorithms, methods and show the outputs of code. (a) show the output of the following code: public class test: public static void main(string[] args){ double e = 1.0: double item = 1.0: for (int I = 1: 1 50: I = -2){ (I = 2 + i) item = item/1: system.out.println(e): } print out the summation of e starting with 1/2 + 1 until 1/50 + 1. Show the output of the following code: public class test { public static void main(string[] args) { int i = 1: What is the output of the following code:Explanation / Answer
a) 1+1/1+1/3+1/5 +1/7 +1/9 +1/11 + ...............+1/49
i = 1,3,5,7,9,11,13,15,................,49
Output:
2.410686134642449
b)
public static void main (String[] args)
{
int i =1;
while(i <= 10)
{
method1(1,i);
i++;
}
}
public static void method1(int i,int num)
{
for(int j=1;j<=i;j++)
{
System.out.println(num+" ");
num += 2;
}
System.out.println();
}
Output:
1
2
3
4
5
6
7
8
9
10
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.