Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do not use any data structures such as array or ArrayList to store data. Write a program as follows a) Prompt the user to input

image text in transcribed
image text in transcribed
Do not use any data structures such as array or ArrayList to store data. Write a program as follows a) Prompt the user to input two distinct integers: nl and n2. b) If the user enters the negative number(s), convert it/them to positive number(s) c) If nl is greater than n2, swap them (make sure nl is smaller than n2) Then, use four separate while loops to do the following: d) Use a while loop to output all the numbers divisible by 5 from nl and n2 inclusive and the sum of these numbers. Use a while loop to output all the numbers not divisible by 5 from nl and n2 inclusive and the average of these numbers. e) f) Use a while loop to output all the odd numbers between n2 to nl (large to small) inclusive Use a while loop to output the table of each even integer and its square between 2 and 16 inclusive. g) Sample run Enter 2 distinet integers Enter first number: 25 Enter second number Numbers divisible by 5 between 4 and 25: 5 10 15 20 25 Sum of these numbers: 75 Numbers not divisible by 5 between 4 and 25: 46 78911 12 13 14 16 17 18 19 21 22 23 24 Average of these numbers: 14.35 Odd numbers between 25 and 4 (large to small): 25 23 21 19 17 15 13 1197 Table of each even integer and its square between 2 and 16: 4 16 6 36 8 64 10 100 12 144 14 196 16 256 2. Write a program that does the following: - Use a while loop to prompt the user to enter 10 objects' weight in pounds. Calculate and output the total and the average weights. - Find and output the highest and the lowest weights. Validate the user input: do not accept negative numbers for the weight. Format the output appropriately with System.out.printf method. Sample Run Enter the object's weight in pounds for object 1: 234.45 Enter the object's weight in pounds for object 2: 56.98 Enter the object's weight in pounds for object 3:125.6 Error: must be nonnegative number! Enter the object's weight in pounds for object 3: 89 Enter the object's weight in pounds for object 4: 67.34 Enter the object's weight in pounds for object 5: 12.2 Enter the object's weight in pounds for object 6: 65.78 Enter the object's weight in pounds for object 7: 63 Enter the object's weight in pounds for object 8:99 Enter the object's weight in pounds for object 9: 200.4 Enter the object's weight in pounds for object 10: 87 Total weight of 10 objects: 975.68 Average weight of 10 objects: 97.57 Highest weight: 234.45

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Identify the potential uses of molecular genetics research.

Answered: 1 week ago

Question

5. Describe the visual representations, or models, of communication

Answered: 1 week ago