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
Free points,
Radda [10]

Answer:

thank you i really needed that and plus i just lost point by putting a question i mean i was asking for help and i still don't know the answer

hope u feel better

5 0
2 years ago
Read 2 more answers
When using the following symbol, there are two arrows coming out of it. One arrow corresponds to what happens in the program if
mariarad [96]

When using the following symbol, there are two arrows coming out of it. One arrow corresponds to what happens in the program if the answer to the question if it is _______YES_____ and the other corresponds to what happens next if the answer to the question is _____NO_____ .

Explanation:

When using the following symbol, there are two arrows coming out of it. One arrow corresponds to what happens in the program if the answer to the question if it is <u>Yes and the other corresponds to what happens next if the answer to the question is No.  </u>

The Below symbol(in attachment ) is used to take decisions. This decision taking step is represented as a diamond in a flowchart.

8 0
2 years ago
23. ____________ is a slide that is used as the base design theme for other slides.​
MatroZZZ [7]

Hmmmmmmmmm, <u>powerpoint</u>?

5 0
2 years ago
Signe wants to improve the security of the small business where she serves as a security manager. She determines that the busine
jek_recluse [69]

Answer:Obscurity

Explanation: Security through the obscurity is the mechanism that is used for the security purpose in an operating system by inducing the confidentiality in the internal parts of the operating system.

The functioning of the security through obscurity(STO) works by hiding the  flaws and errors related to security  of the operating system.Thus , Signe is willing to use obscurity system.

 

6 0
3 years ago
What are some examples of environmental technology
Zarrin [17]
Some examples of environmental technology is recycling.
3 0
3 years ago
Other questions:
  • Candace opened an email from a person she didn't know and clicked on a pop-up in the email that installed a virus on her compute
    8·2 answers
  • If you plan on operating several applications at s time, the amount of RAM should be considered when purchasing a computer
    10·2 answers
  • You are troubleshooting an interface issue on your cisco ios isr. the output of "show ip interface brief" indicates that etherne
    11·1 answer
  • An OR function nested in an IF function results in
    11·1 answer
  • What is a benefit of the rise in citizen journalism? Multiple answer choice below
    13·1 answer
  • Tom and his brother caught 100 finish on a weeklong fishing trip. The total way of the fish was 235 pounds. What is the weight o
    9·1 answer
  • Why is yo utu be down?<br> (You restrict talking about yo utu be, really)
    11·2 answers
  • When you open a program, the hard drive
    7·1 answer
  • Because of increasing advances in technology, there are careers available that weren’t even invented 10 years ago. One such care
    13·1 answer
  • What does syntax error mean :-;<br>explain briefly.<br><br>thankyou!
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!