Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use java please follows: Prompt the user to input two positive integers: nl and n2 (nl should be less than n2). b. If the user

Use java please image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
follows: 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). 1. (10 points) Write a program as a. c. Ifnl is greater than n2, swap them. d. Use a while loop to output all the even numbers between nl and n2. Use a while loop to output the sum of all the odd numbers between nl and n2. e. f. 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. nun: Enter two numbers (First number must be less than the second nunber) Enter the first nunber: 21 Enter the second number: 5 Even integers between 5 and 21 are: 6 8 10 12 14 16 18 20 Sum of odd integers between 5 and 21 - 117 Sum of the squares of odd integers between 5 and 21-1520 Lower case letters are: a b e d e : g h i iti ra0Pgrs turuan (10 peints) Driving Cest Program 2. Drivers are concerned with the mileage obtained by their automobiles, 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 each 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/ourpur dialog schA Enter the gallons used (-1 to end): 12.8 Enter the miles driven: 287 The miles /gallon for this tank was 22.4 Enter the gallons used (-1 to end): 10.3 Enter the miles driven: 200 The miles/gallon for this tank was 19.4 Enter the gallons used (-1 to end):5 Enter the wiles driven: 120 The miles / gallon for this tank was 24.0 Enter the gallons used (-1 to end): -1 The overal1 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 with AI-Powered 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