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
Why does dns use udp instead of tcp? if a dns packet is lost, there is no automatic recovery. what are the consequences?
inysia [295]
<span>If a DNS packet using UDP is lost this problem must be handled at the application layer. If an answer is not received after some period of time the specific application may choose to resend the DNS query. I can go much more into detail but this should answer your question. If you need more detail just ask.</span>
6 0
3 years ago
Need Help Please
erastova [34]

Answer:

1. siblings + 1

2. numberOfPizzas * pizzaCost

3. alienGreeting + alienGreeting2

4. color1 === color2

5. value1 - value2

6. console.log(gradeAverage === gradeAverage2)

7. numberToString + numberToString2

8. numberOfStudents / numberOfClassrooms

9. console.log(carSpeed === truckSpeed)

4 0
3 years ago
If a printer can print 10 characters per second how many minutes (rounded) would it take to print a page with 66 lines of 80 cha
maks197457 [2]

Answer:

8.8 Minutes

Explanation:

10 characters per second and 80 characters per line. 80/10=8 describes how many seconds it would take per line. Then multiply the time it takes per line by the number of lines which would be 8x66. Then from there you get 528 seconds and by doing some divison you get 8.8 minutes.

3 0
3 years ago
Which of the following dimensions of e-commerce technology has the potential to raise the quality of information? A) Global reac
masya89 [10]

Answer:

D. Information density.

Explanation:

E-commerce is the online trading of goods and service between a buyer and a seller, with integrated payment medium. This website technology provides an e-store and needs information on the client data to provide the necessary services.

Information density is the total amount and quantity of information available to all participating in e-commerce. This provides a rich quality and database of information for e-commerce website technology, to enhance the quality of services in e-commerce, information density must be considered.

7 0
3 years ago
Join my giggl PLEASE i am so bored link will be in comments
asambeis [7]

Answer:

in which app we had to join

5 0
3 years ago
Read 2 more answers
Other questions:
  • Users of an extranet can access a company or organization’s entire intranet
    8·2 answers
  • Do all accounts use the same routing number
    12·1 answer
  • What special precautions should you take when detailing a steel-framed building to avoid excessive conduction of heat through th
    9·1 answer
  • Refer to the exhibit. The web servers WS_1 and WS_2 need to be accessed by external and internal users. For security reasons, th
    12·1 answer
  • Can i add ADSence on bangla content in blogsopt website?
    12·1 answer
  • BRAINLIEST You have a small company and want to keep your costs low, but it is important your employees share data. Which networ
    13·2 answers
  • All the network nodes are connected to each other
    8·1 answer
  • What is the fundamental purpose of sentiment analysis on social media?​
    9·1 answer
  • Diane changes the size of an image with the format picture pane and keeps the original ratio of height to width of the object. W
    8·1 answer
  • julie was just hired to conduct a security assessment of dion training’s security policies. during her assessment, she noticed t
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!