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
A form that dedicates a page for each item retrieved for a case; it allows investigators to add more detail about exactly what w
gregori [183]

Answer:

Single-evidence form​

Explanation:

Single-evidence form​  dedicates a page for each item retrieved for a case; it allows investigators to add more detail about exactly what was done to the evidence each time it was taken from the storage locker.

4 0
3 years ago
Discuss the various types of keys available on a computer keyboard.<br>No spam answer needs!❌❌​
olga nikolaevna [1]

Answer:• Alphanumeric keys – all of the letters and numbers on the keyboard. A-Z and 0-9.

• Punctuation keys – All of the keys associated with punctuation such as the comma,

period, semicolon, brackets, parenthesis and so on. Also, all of the mathematical

operators such as the plus sign, minus sign, and equal sign.

• Special keys – All of the other keys on the computer keyboard such as the function

keys, control keys, arrow keys, caps lock key, delete key, etc.

Special keys on a PC Keyboard

• Alt key – Short for Alternate, this key is like a second control key.

• Arrow Keys – Most keyboards have four arrow keys that enable you to move the

cursor (or insertion point) up, down, right, or left. Used in conjunction with the Shift

or Alt keys, the arrow keys can move the cursor more than one position at a time, but

this depends on which program is running.

• Backspace key – Deletes the character just to the left of the cursor (or insertion

point) and moves the cursor to that position.

• Caps Lock Key – A toggle key that, when activated, causes all alphabetic characters

to be uppercase.

• Ctrl key – Short for Control, this key is used in conjunction with other keys to

produce control characters. The meaning of each control character depends on which

program is running.

• Delete Key – Sometimes labeled Del, deletes the character at the current cursor

position, or the selected object, but does not move the cursor. For graphics-based

applications, the Delete key deleted the character to the right of the insertion point.

• Enter Key – Used to enter commands or to move the cursor to the beginning of the

next line. Sometimes labeled Return instead of Enter.

• Esc Key – Short for Escape, this key is used to send special codes to devices and to

exit (or escape) from programs and tasks.

• Function Keys – Special keys labeled F1 to F12. These keys have different meaning

depending on which program is running.

Explanation: use quillbot or wordtune to change the words

3 0
2 years ago
Which pattern is produced by the following code? for (int i = 1; i &lt;= 6; i++) { for (int j = 6; j &gt;= 1; j--) System.out.pr
Brrunno [24]

Answer:

              1                                                                                                                    

           2 1                                                                                                                    

        3 2 1                                                                                                                    

     4 3 2 1                                                                                                                    

  5 4 3 2 1                                                                                                                    

6 5 4 3 2 1

Explanation:

I do not now know which option it corresponds but the shape should look like above.

The logic is following;

There is a nested for loop. The inner loop prints the value of j, when j is smaller than or equal to i. Otherwise, it prints a space.

For example, in the first iteration i = 1 and j starts from 6.

i = 1, j = 6 -> print space

i = 1, j = 5 -> print space

i = 1, j = 4 -> print space

i = 1, j = 3 -> print space

i = 1, j = 2 -> print space

<u>i = 1, j = 1 -> print j</u>

3 0
3 years ago
What is said to be the first mechanical calculator​
lakkis [162]

Answer:

Pascaline, also called Arithmetic Machine, the first calculator or adding machine to be produced in any quantity and actually used. The Pascaline was designed and built by the French mathematician-philosopher Blaise Pascal between 1642 and 1644.

Explanation: hope that helps

8 0
3 years ago
Read 2 more answers
In a paragraph, describe in detail a practical real-world example of where you would implement a singly-linked list and why a si
frosja888 [35]

Answer:

travel

Explanation:

One real world example of a singly-linked list would be travel. Imagine that you want to take a trip to your nearest neighbor state. To do so you would need to take a 2 buses and a train, but you can't just take any or in any order you wish. You first need to take the first bus at your current location, get off at the train station, take that train to the final stop, get off and take the bus to the final destination. Meaning there is a sequence of connected events that you must follow in order to get to your destination and the same opposite sequence of events to get back. This is exactly like a singly-linked list.

3 0
3 years ago
Other questions:
  • Which of the following are stages in the computer life cycle? Check all of the boxes that apply.
    13·2 answers
  • What are strategies that you can use to yield web sites that are relevant to your research topic?
    13·1 answer
  • Suppose the program counter (pc) is set to 0x2000 0000. is it possible to use the jump (j) mips assembly instruction to set the
    15·1 answer
  • on 5.7.3, we provide an outline of a solution to the dining-philosophers problem using monitors. This problem will require imple
    6·1 answer
  • How many fonts are there in a theme?<br> A. 1<br> B. 2<br> C. 4<br> D. 5
    10·1 answer
  • How to construct a speaking library presentation database. How will you use this library and database in the furture? Based on w
    10·1 answer
  • In Java; Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or
    15·1 answer
  • _______is a network of physical objects embedded with sensors, processors, software and network connectivity capability to enabl
    6·1 answer
  • Which two tools used for incident detection can be used to detect anomalous behavior, to detect command and control traffic, and
    13·1 answer
  • The ________ encloses and protects the power supply, motherboard, processor, and memory of a computer. drive bay solid-state sto
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!