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
Over a TCP connection, suppose host A sends two segments to host B, host B sends an acknowledgement for each segment, the first
irinina [24]

Over a TCP connection, suppose host A sends two segments to host B, host B sends an acknowledgement for each segment, the first acknowledgement is lost, but the second acknowledgement arrives before the timer for the first segment expires is True.

True

<u>Explanation:</u>

In network packet loss is considered as connectivity loss. In this scenario host A send two segment to host B and acknowledgement from host B Is awaiting at host A.

Since first acknowledgement is lost it is marked as packet lost. Since in network packet waiting for acknowledgement is keep continues process and waiting or trying to accept acknowledgement for certain period of time, once period limits cross then it is declared as packet loss.

Meanwhile second comes acknowledged is success. For end user assumes second segments comes first before first segment. But any how first segment expires.

3 0
2 years ago
What command do you use to increase or decrease the view of a selected cell or range of cells to fill the excel window area for
kap26 [50]

Zoom to selection is the command that should be used to increase or decrease the view of a selected cell or range of cells to fill the excel window area for better visibility

I hope this will help you.

7 0
2 years ago
When you write a program that will run in a GUI environment as opposed to a
givi [52]

When you write a program that will run in a GUI environment as opposed to a

command-line environment, some syntax is different.

Explanation:

  • GUI (Graphical User Interface) which is the computer user interface uses graphical images to activate and run the applications.
  • Command line interface is a interface that is in a text format, which can accept commands for a task.
  • So, to program both interface, we need high level program skills with good understanding in programming languages like C++, C etc and algorithms.
  • Here, the GUI syntax differs from the command line interface.
8 0
3 years ago
What minimal operating system has only the services needed to access the network, work with files, copy disk images, and jump-st
Anika [276]

Answer:

The correct answer to the following question will be "Windows Preinstallation Environment".

Explanation:

  • WinPE is a portable Windows edition used only to launch computers, pcs, and servers, workstations or to troubleshoot an OS when offline.
  • It's often designed to accommodate boot drives of MS-DOS and it can be unlocked or booted from USB drive, CD-ROM, PXE or hard disk drive.
  • This only has the resources available to network accessing, to deal with files, to clone disk items and to launch a Windows update.

Therefore, it's the right answer.

5 0
3 years ago
What is the purpose of the "def" keyword in Python?
Pani-rosa [81]

Answer:

d) b and c are both true.

Explanation:

The purpose of def keyword in python is to indicate start the function and it also indicates that the piece of code following the def keyword is to stored so that it can later be used in the program.

For ex:

def check(n):

   if n==10:

       return True

   return False

   

n=int(input("Enter an integer\n"))

if check(n):

   print("n is 10")

else:

   print("n is not 10")

In the above written code the function check is defined by using the keyword def.It also tells the interpreter to store the code because we will need it in future.

4 0
3 years ago
Other questions:
  • How is prior video game experience related to Top Gun scores? Select the correct conlcusion. a. Surgeons who have played some vi
    8·1 answer
  • ENG103 DISCUSSION BOARD 6
    15·1 answer
  • Computer _____ begins with regular maintenance of the computer system such as firewalls, antivirus programs, defragmentation, de
    7·1 answer
  • Which is true about POP3 and IMAP for incoming email?
    10·1 answer
  • Which line in the following program will cause a compiler error? #include using namespace std; int main() { int number =5; if (n
    10·1 answer
  • Which of these is an aggregator?
    9·2 answers
  • HELP!!!<br> THIS HAPPENS EVERY TIME
    6·2 answers
  • Describe the Order of Operations in Java programming.
    11·1 answer
  • Radio spectrum is the part of the complete range of electromagnetic waves that is used for radio communication from
    14·1 answer
  • TQ Automation<br> What is Robotic Process Automation (RPA)?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!