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
Betty took her friends bowling. they rented 4 lane. 10 people need rent shoes and
bogdanovich [222]
First there are two groups, members and non-members, so you know that there are 4 people who are members, if you subtract 4 from ten that would mean 6 people are non-members. now, for the cost of the members would be (7.50 × 4) + (2.95 × 4) = 41.8$
for the non-member group or would be (9.75 × 6) + (3.95 ×6) = 82.2$ now add 41.8 to 82.2 which equals 124.0$ in total
4 0
3 years ago
ITS A VOTE I NEED HELP
Mandarinka [93]

Answer: A block-level element is any element that starts a new line.

4 0
3 years ago
The Status bar is used to control the majority of the drafting settings in AutoCAD
kifflom [539]

The answer is "true"

Hope this helps!

6 0
3 years ago
What do you call the quality of information
Kobotan [32]

Answer:

"Information quality" is a measure of the value which the information provides to the user of that information. accuracy, objectivity, Believability, reputation.

Explanation:

8 0
3 years ago
Hello my friends i am trying to reboot my i phone 4 but i could not i tried many ways can u help me
g100num [7]

Answer:

Launch iCloud.com in the web browser on your PC.

After the page opens, enter the credentials; username and password.

On the screen, after you login, you’ll see all iDevices you’ve associated...

Choose "Erase operation" for devices you can’t log inside.

or

Connect your iPhone to a computer. If your iPhone gets hung up on the Apple logo or a solid-color screen when forcing it to restart, you can try using your PC or Mac to repair it without losing data. Start by connecting the iPhone to the computer using its charging cable.

2

Open Finder (Mac) or iTunes (PC). If you're using Mac Catalina or later, click the two-toned face on the Dock to launch Finder. If you have Windows or an earlier version of macOS, open iTunes from the Start menu or Applications folder. Locate your iPhone. If you're using Finder, click your iPhone's name in the left panel under "Locations." If you're using iTunes, click the button with an iPhone icon near the top-left corner of the app (to the right of the drop-down menu)

Explanation:

8 0
3 years ago
Other questions:
  • A web client is sending a request for a webpage to a web server. from the perspective of the client, what is the correct order o
    14·1 answer
  • What is the leading use of computers
    15·2 answers
  • How would you define a relational database ?
    12·1 answer
  • What is the importance of human flourishing to science and technology?​
    8·1 answer
  • How many pounds must a sand bag weigh to test if a safety net can absorb the proper amount of force? A. 150 lbs. B. 200 lbs. C.
    6·1 answer
  • In 1981, the first digital icons were launched for users in _________, which was the first computer with a GUI operating system.
    12·1 answer
  • Jon wants to assign a value to the favorite food variable: favoriteFood! = "Pizza" but gets an error message. What does he need
    9·2 answers
  • What is essential for a good study routine? Select four options.
    7·1 answer
  • Which is an example of a demand account
    10·1 answer
  • What is Utility Software ? Name any two utility programs. <br>​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!