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
How many levels of heading tags are allowed in html?
nirvana33 [79]

Answer:

six levels

Explanation:

HTML defines six levels of headings. A heading element implies all the font changes, paragraph breaks before and after, and any white space necessary to render the heading. The heading elements are H1, H2, H3, H4, H5, and H6 with H1 being the highest (or most important) level and H6 the least.

5 0
2 years ago
Read 2 more answers
1) The program reads an integer, that must be changed to read a floating point. 2) You will need to move that number into a floa
DochEvi [55]

Answer:

1. Get the number

2. Declare a variable to store the sum and set it to 0

3. Repeat the next two steps till the number is not 0

4. Get the rightmost digit of the number with help of remainder ‘%’ operator by dividing it with 10 and add it to sum.

5. Divide the number by 10 with help of ‘/’ operator

6. Print or return the sum

# include<iostream>

using namespace std;

/* Function to get sum of digits */

class gfg

{

   public:

   int getSum(float n)

   {

   float sum = 0 ;

   while (n != 0)

   {

    sum = sum + n % 10;

    n = n/10;

   }

return sum;

}

};

//driver code

int main()

{

gfg g;

float n = 687;  

cout<< g.getSum(n);

return 0;

}

Explanation:

6 0
3 years ago
What do the following standards cover?
steposvetlana [31]

Answer:

ANSI/TIA/EIA-570-B - Residential telecommunications

ANSI/TIA/EIA-606-A - Administration

ANSI/TIA/EIA-607 - Grounding and Bonding

Explanation:

The first standard is generally used for residential telecommunication. This is mainly for the form of telecommunications used in residential areas. The second standard is mainly used for administrative purposes such as those in offices. Furthermore, the third standard is applicable to grounding and bonding purposes.

8 0
3 years ago
Part 2: Code the Program
OverLord2011 [107]

Answer:

# Name - Today's Date

# Description

def main():

    print("My favorite TV show is Mythbusters.")

    print("I like it because I learn a lot and they do crazy experiments.")

main()

(this is the best I can do since it's a specific result based on the choices you make, but I did the example code and you just need to fill it in with the necessary requirements. I also tested it on IDLE. )

8 0
3 years ago
Do people answer questions more on this site or be on social more ??? no right or wrong answer your opinion
aniked [119]

for school this site and for everything else social midia

3 0
3 years ago
Other questions:
  • What is a Photojournalist
    5·1 answer
  • Terms that represents the achual speed used by device to transfer data​
    14·1 answer
  • What is the value of variable num after the following code segment is executed?
    5·1 answer
  • What are youth oraganizations?
    7·1 answer
  • Cual es la definición de grouded?​
    7·1 answer
  • The __________ utility has the capability to manage users, create and administer user groups, and apply user rights to those use
    8·1 answer
  • The first idea for a communications network was called
    14·2 answers
  • Which of the following screen elements is a horizontal bar that displays at the
    8·1 answer
  • You send a friend a private message about something personal that is going on with you. Without permission, she forwards your te
    10·1 answer
  • A character that <br>is raised and smaller above the baseline is called​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!