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
Consider a physical address with a page frame size of 2kb. how many bits must be used to represent the page-frame offset of the
MArishka [77]
11 bits would be enough for 0 - 2047 decimal, 2048 (2k) possible values. 2048 itself would need a 12 bit, which would allow from 0 - 4095 possible values. Useful tidbit to remember: 1024, 1k is ten bits.
7 0
4 years ago
Game Design Help please
vova2212 [387]

Because, to put it simply, to use more complicated shapes requires more processing power which is unnecessary. Only if they would touch all parts of the shape should it be complicated.

5 0
3 years ago
Which of these represents the output of NOT logic? It is the inverse of the input. It is the expression of the input. It is the
lord [1]
The correct amswer would be (c)
6 0
3 years ago
Read 2 more answers
What is a return statement used for?
Aleonysh [2.5K]

Answer:

Exiting a function

Explanation:

Return simply returns a specified value at the end of a def function (if you're in python). It does not print or do anything else. You could set variables equal to a def function that returns or you could put the def function in a print statement to print the returned value.

4 0
3 years ago
If you enjoy working with livestock, the best cluster in which to research careers would be: A. Health Science. B. Agriculture,
Pachacha [2.7K]

Answer:

B. Agriculture, Food, and Natural Resources.

Explanation:

The Agriculture, Food and Natural Resources career cluster is for those students who enjoy the outdoors and love working with both animals and plants. The cluster prepares most students for careers in agriculture products and services. This cluster includes a wide range of job occupations such as livestock farmer, florist, and many more. The animal systems career pathway will specifically deal with the business side of livestock. This career pathway will further include students who would want to work as animal breeders, farm workers, animal scientists, or nonfarm animal caretakers.

7 0
3 years ago
Other questions:
  • What can you say about the following Java class definition?
    10·1 answer
  • Which visual aid would help a group of veterinary students study a dog's anatomy?
    14·1 answer
  • The __________ determines whether coolant should be pumped back into the engine directly or cooled first.
    15·1 answer
  • Alice just wrote a new app using Python. She tested her code and noticed some of her lines of code are out of order. Which princ
    8·1 answer
  • You run a small network for your business that has a single router connected to the Internet and a single switch. You keep sensi
    11·1 answer
  • I - For any two points on the Internet, there exists only one path between the two points II - Routing on the Internet is fault
    12·1 answer
  • When installing a device driver, start the computer in
    6·1 answer
  • Consider the following code segment.
    10·1 answer
  • Please help I really don't understand much about web technology.
    8·1 answer
  • PLEASE HELP THIS IS CONFUSING ME
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!