Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use a java program that does the following: . (10 points) Write a program as follows a. Prompt the user to input two positive integers:

Use a java program that does the following: image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
. (10 points) Write a program as follows a. Prompt the user to input two positive integers: nl and n2 (nl should be less than 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. d. Use a while loop to output all the even numbers between nl and n2 e. Use a while loop to output the sum of all the odd numbers between n and n2 r. Use a while loop to output the sum of squares of all the odd numbers between nl and n2 g. Use a while loop to output all the lower case letters Sample run Enter two numbers (First number must be less than the second number) Enter the first number:-21 Enter the second number:S Even integers between 5 and 21 are: 6 8 10 12 14 16 8 20 Sum of odd integers betveen 5 and 21- 117 Sum of the squares of odd integers betveen 5 and 21-1761 Lower case letters arerabedefghijkinnoPqEstuvwxy z 2. (10 points) Driving Cost Program Drivers are concerned with the mileage obtained by their One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. De velop a program that will input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for cach tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls. Here is a sample input/output dialog: Enter the gallons used C-1 to end): 12.8 Enter the ales driven: 287 The miles/gallon for this tank was 22- Enter the gallons used C-1 to end): 10.3 Enter the miles driven: 200 The miles/gallon for this tank was 19- Enter the gallons used C-1 to end): 5 Enter the miles driven: 120 The miles/gallon for this tank was 24.0 Enter the gallons used C-1 to end):-1 The overall average miles/gallon was 21.6

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

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions