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
Who tryna play among us
harkovskaia [24]

Answer:

I'm doing a digital media test right now

8 0
3 years ago
Read 2 more answers
Enables businesses and consumers to share data or use software applications directly from a remote server over the Internet or w
Sindrei [870]

Answer:

Cloud Computing        

Explanation:

Cloud Computing is basically an infrastructure to deliver various computing resources and services  to the users online (via Internet). These resources include networks, applications, servers, databases, software, storage etc.

These services are mostly utilized by organizations for recovery and backup of data, using virtual hardware and other computing resources such as desktops, memory etc. Cloud computing is also used for developing software, for securing data by providing with access control and for storing bulk of data.

The benefits of cloud computing are as following:

Because of cloud computing the customers do not have to buy hardware or install software on their computer which might be very costly to maintain and update. Servers and data centers are provided by cloud service providers and experts are available for managing the services and resources.

These services are scalable and can be adjusted as per the users requirements.

Cloud computing offers a variety of protocols, tools, and access controls that improve security and protects confidential data, applications, and networks against security threats and attacks. It also provides with data backup, disaster recovery.

5 0
3 years ago
Create a list of strings based on a list of numbers The rules:_______
Delicious77 [7]

Answer:

listNumbers = [34,56,23,56,78,89,98,45,34,33,25,26,67,78]

listString = [ ]

for i in range(14):

   if listNumbers[i]%2!=0 and listNumbers[i]%5==0:

       listString.append("five odd")

   elif listNumbers[i]%5==0 and listNumbers[i]%2==0:

       listString.append("five even")

   elif listNumbers[i]%2==0:

       listString.append("even")

   elif listNumbers[i]%2!=0:

       listString.append("odd")

print(listNumbers)

print(listString)

Explanation:

In python programming language;

  1. Create two lists
  2. The first is a list of numbers and initialize it with random values: listNumbers = [34,56,23,56,78,89,98,45,34,33,25,26,67,78]
  3. The second list is empty and will hold the string values listString = [ ]
  4. Use a for loop to iterate over all the elementts in the list of numbers
  5. Use the modulo operator (%) to chech for multiples of particular numbers as stipulated by the question
  6. Use combination of if/elif statements for each condition
  7. Use the .append method to add the elements into the list of strings
  8. finially output both lists

See attached code and output

3 0
3 years ago
Write a program that prints to the screen all the ASCII characters from 33 to 126. 33! 34''
leonid [27]

Answer:

#include <iostream>

using namespace std;

int main() {

   for(int i=33;i<=126;i++)//Using loop to print ASCII characters.

   {

         cout<<i<<char(i<<" ";//statement to print integer and it's ASCII characters with values.

   }

return 0;

}

Explanation:

Put a closing parenthesis i char(i after doing that code will run .Since the answer was not getting posted hence i have to come to this resort.

I have used for loop for values 33 to 126 and for printing the ascii characters I have used typecasting converting the integer to corresponding char forcefully.

6 0
3 years ago
What time is spellrd the same forwards and backwards​
Juliette [100K]
12:21 is the correct answer
6 0
3 years ago
Other questions:
  • The equation y=2x+1 represents a function true or false
    11·1 answer
  • Which type of color mixing do painters with a real brush and paints use?
    5·1 answer
  • Which statement correctly describes how the density and temperature of air is related .
    7·1 answer
  • Anne-Marie Cole runs the sales division for a local auto insurance firm. One of her key duties is to calculate her company's mar
    13·1 answer
  • The advantage of an electronic ____ is that the content can be easily edited and updated to reflect changing financial condition
    10·1 answer
  • SAN Security Issues: What storage security issue might come to be a greater problem in the future?
    10·1 answer
  • Suppose that you have created a program with only the following variables.int age = 34;int weight = 180;double height = 5.9;Supp
    7·1 answer
  • Different network devices function at different network communication layers, depending on their purpose. Using the TCP/IP model
    7·1 answer
  • please help me out i’ll give you brainlist
    14·1 answer
  • Significant design efforts, during deliberate planning at combatant commands, produce results as those commands _____. (Select a
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!