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
MAVERICK [17]
2 years ago
6

JAVA -Develop a program that prompts the user to enter a series of 10 integers and then determines and displays the largest and

smallest values entered. The solution must use at least these following variables:
counter -a counter to count how many integers were entered
number -the integer most recently input by the user
smallest -the smallest number entered so far
largest -the largest number entered so far

Write three separate programs in JAVA , the first using a while construct, the second using a for construct, and the third using a do while construct. Thank you so much!
Computers and Technology
1 answer:
MariettaO [177]2 years ago
8 0

Using the knowledge in computational language in JAVA it is possible to write a code that enter a series of 10 integers and then determines and displays the largest and smallest values entered.

<h3>Writting the code in JAVA:</h3>

<em>public class OddEvenSum {  </em><em>// Save as</em><em> "OddEvenSum.java"</em>

<em>   public static void main(String[] args) {</em>

<em>   </em><em>   // Declare variables</em>

<em>      final int LOWERBOUND = 1;</em>

<em>      final int UPPERBOUND = 1000;  // Define the bounds</em>

<em>      int sumOdd  = 0;    // For accumulating odd numbers, init to 0</em>

<em>      int sumEven = 0;    // For accumulating even numbers, init to 0</em>

<em>      int absDiff;        // Absolute difference between the two sums</em>

<em>      // </em><em>Use a while loop</em><em> to accumulate the sums from LOWERBOUND to UPPERBOUND</em>

<em>      int number = LOWERBOUND;   // loop init</em>

<em>      while (number <= UPPERBOUND) {  // loop test</em>

<em>            // number = LOWERBOUND, LOWERBOUND+1, LOWERBOUND+1, ..., UPPERBOUND</em>

<em>         // A if-then-else decision</em>

<em>         if (number % 2 == 0) {  // Even number</em>

<em>            sumEven += number;   // Same as sumEven = sumEven + number</em>

<em>         } else {                // Odd number</em>

<em>            sumOdd += number;    // Same as sumOdd = sumOdd + number</em>

<em>         }</em>

<em>         ++number;  // loop update for next number</em>

<em>      }</em>

<em>      // </em><em>Another if-then-else</em><em> Decision</em>

<em>      if (sumOdd > sumEven) {</em>

<em>         absDiff = sumOdd - sumEven;</em>

<em>      } else {</em>

<em>         absDiff = sumEven - sumOdd;</em>

<em>      }</em>

<em>      // OR </em><em>using one liner </em><em>conditional expression</em>

<em>      //absDiff = (sumOdd > sumEven) ? sumOdd - sumEven : sumEven - sumOdd;</em>

<em> </em>

<em>      // </em><em>Print the results</em>

<em>      System.out.println("The sum of odd numbers from " + LOWERBOUND + " to " + UPPERBOUND + " is: " + sumOdd);</em>

<em>      System.out.println("The sum of even numbers from " + LOWERBOUND + " to " + UPPERBOUND + " is: " + sumEven);</em>

<em>      System.out.println("The absolute difference between the two sums is: " + absDiff);</em>

<em>   }</em>

<em>}</em>

See more about JAVA at brainly.com/question/12975450

#SPJ1

You might be interested in
Were is the hype house
balandron [24]

Answer:

LA

Explanation:

where the rich people live

8 0
2 years ago
Read 2 more answers
If an ARQ algorithm is running over a 40-km point-to-point fiber optic link then:
Dennis_Churaev [7]

Answer and Explanation:

Given data:

Distance (D) = 40 KM

Speed of light in the fiber =Distance/ speed of light in the fiber

a) Delay (P) = Distance/ speed of light in the fiber

= (40,000 Meters/2×108 m/s)

=( 40×103 Meters/2×108 m/s)

Propagation delay (P) = 0.0002 seconds or 200 microseconds

b)

if propagation delay is 0.0002 Seconds roundup trip time (RTT) will be 0.0004 Seconds or 400 micro Seconds

Essentially since transmission times and returning ACKs are insignificant all we really need is a value slightly greater than 0.0004 seconds for our timeout value.

c)

The obvious reasons would be if the data frame was lost, or if the ACK was lost. Other possibilities include extremely slow processing on the receive side (late ACK).

Or Extremely Slow Processing of the ACK after it is received back at the send side.

4 0
3 years ago
[1] Our son has started playing organized T-ball, a beginner’s version of baseball. [2] “Organized” is what parents call it, any
k0ka [10]
I think it is 3 no? Maybe I dunno but I am confident
6 0
2 years ago
Read 2 more answers
A. What is MS-Word ? Write its uses.
solmaris [256]

Answer:

MS word is Microsoft word and you can use MS Word in daily life and business to create professional-looking documents such as resume, letters, applications, forms, brochures, templates, business cards, calendars, reports, eBooks, and newsletters in speed with high quality.

Explanation:

6 0
3 years ago
Read 2 more answers
Write a shell (text-based) program, called sum_second.py, that opens a text file called stuff.txt with 2 numbers per line separa
Ivanshal [37]

Answer:

See explaination for the program code

Explanation:

The Programming code:

inFile = open("stuff.txt", "r")

num = []

Sum = 0

for val in inFile.readlines():

value = val.split(",")

Sum = Sum + int(value[1])

print("Sum of second number on every line in the file is: ", Sum)

inFile.close()

Please kindly check attachment for output

6 0
3 years ago
Other questions:
  • In this type of network, data is certain to reach its destination.
    7·1 answer
  • ‘Bottom of the pyramid’ innovation refers to ancient Egyptian approaches to new product development – true or false?
    8·1 answer
  • Most browsers allow you to maintain your most frequently visited websites. what is this called? Special place holder, secret lis
    6·2 answers
  • What in the LAN for a small office, some user devices connect to the LAN using a cable, while others connect using wireless tech
    14·1 answer
  • If you do not want to keep a change made by the autocorrect feature, you can click the ____ button on the auto correction option
    12·1 answer
  • How do cyber criminals target user’s end devices?
    11·2 answers
  • A web-based program that uses artificial intelligence techniques to automate tasks such as searches is called
    8·1 answer
  • Help me please. I dont really understand this.
    12·2 answers
  • !!! PLEASE HELP ASAP REALLY NEED IT !!!
    15·2 answers
  • Jason is the motion picture projectionist at the local IMAX theater. This means that he runs the huge movie projector so that cu
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!