1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dusya [7]
3 years ago
7

In Java.Use a single for loop to output odd numbers, even numbers, and an arithmetic function of an odd and even number. Use the

numbers in the range [ 0, 173 ]. Note that the square brackets indicate inclusion of the endpoints. 0 (zero) is considered an even number. Format your output to 4 decimal places.Do not use any branching statements (if, if-else, switch, ... )Your output should be professional in appearance and formatted. Use at least one control character in your output other than '\n'.Document your code.Using your loop, display the following in a single line on the console:Odd number even number sqrt( odd number + even number)Your output should look like this (this is a partial example for the numbers [0, 173].1.0000 3.0000 5.0000 7.00000.0000 2.0000 4.0000 6.00001.0000 2.2361 3.0000 3.6051
Computers and Technology
1 answer:
rosijanka [135]3 years ago
7 0

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

}

Download java
You might be interested in
What is a command-line interactive scripting environment that provides the commands for almost any management task in a Windows
hoa [83]

Answer:

kqwbxskwsxe

Explanation:

menb dhj

8 0
3 years ago
All of these (except the ______) go unnoticed by the computer
astra-53 [7]
VIRUS I SERIOUSLY DONT KNOW THOUGH

5 0
3 years ago
Black and white squares codehs, i need the whole code (40 points for correct answer)
ludmilkaskok [199]

Answer:

speed(0)

penup()

setposition(-100,0)

count=0

def make_squares(i):

if i % 2 == 0:

begin_fill()

for i in range(4):

forward(25);

left(90)

end_fill()

penup()

pendown()

for i in range(6):

pendown()

make_squares(i)

penup()

forward(35)

Explanation:

3 0
2 years ago
Read 2 more answers
..........................................
Scilla [17]

Answer:

jhhgvjgfhvbnbjvjn

Explanation:

7 0
2 years ago
Read 2 more answers
Can someone tell me what all of these are?
Allisa [31]

Answer:

parts of a camera

Explanation:

5 0
3 years ago
Other questions:
  • What is cryptocurrency ? I need to do a research one it please help!
    6·1 answer
  • What is the range of the well-known ports used by tcp and udp?
    5·1 answer
  • Doe's anyone know how to access developer mode on a Chromebook laptop if enterprise enrollment blocks it?
    14·2 answers
  • You are a project manager tasked to implement a critical application in a reputed bank. A client review indicates that you could
    11·2 answers
  • What do the points on this website do?
    14·2 answers
  • ABC software company is to develop software for effective counseling for allotment of engineering seats for students with high s
    13·1 answer
  • What is the name of the virus that appears to be a legitimate program but when opened
    9·1 answer
  • How are logical operators used?
    14·1 answer
  • When you login to your blogging account. The first screen with all controls, tools and functions is called .... Select one: a. D
    10·1 answer
  • The banner on the front page of a newsletter that identifies the publication is the:.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!