Answer:
<em>This program is written using java programming language</em>
<em>Difficult lines are explained using comments (See Attachment for Source file)</em>
<em>Program starts here</em>
import java.util.*;
import java.lang.Math;
public class oddeven{
public static void main(String [] args)
{
double even,odd;//Declare variables even and odd as double
//The next iteration prints odd numbers
for(int i = 1;i<=173;i+=2)
{
odd = i;
System.out.format("%.4f",odd);//Round to 4 decimal places and print
System.out.print("\t");
}
System.out.print('\n');//Start printing on a new line
//The next iteration prints even numbers
for(int i = 0;i<=173;i+=2)
{
even=i;
System.out.format("%.4f",even);//Round to 4 decimal places and print
System.out.print("\t");
}
System.out.print('\n');//Start printing on a new line
double ssqrt;//Declare ssqrt to calculate the square root of sum of even and odd numbers
for(int i = 0;i<=173;i+=2)
{
ssqrt = Math.sqrt(2*i+1);//Calculate square root here
System.out.format("%.4f",ssqrt); //Round to 4 decimal places and print
System.out.print("\t");
}
}
}
Explanation:
Libraries are imported into the program
import java.util.*;
import java.lang.Math;
The following line declares variables even and odd as double
double even,odd;
The following iteration is used to print odd numbers with in the range of 0 to 173
for(int i = 1;i<=173;i+=2) {
odd = i;
System.out.format("%.4f",odd); This particular line rounds up each odd numbers to 4 decimal places before printing them
System.out.print("\t"); This line prints a tab
}
The following code is used to start printing on a new line
System.out.print('\n');
The following iteration is used to print even numbers with in the range of 0 to 173
for(int i = 0;i<=173;i+=2)
{
even=i;
System.out.format("%.4f",even); This particular line rounds up each even numbers to 4 decimal places before printing them
System.out.print("\t"); This line prints a tab
}
The following code is used to start printing on a new line
System.out.print('\n');
The next statement declares ssqrt as double to calculate the square root of the sum of even and odd numbers
double ssqrt;
for(int i = 0;i<=173;i+=2)
{
ssqrt = Math.sqrt(2*i+1);This line calculates the square root of sum of even and odd numbers
System.out.format("%.4f",ssqrt); This particular line rounds up each even numbers to 4 decimal places before printing them
System.out.print("\t"); This line prints a tab
}