3) Create a Java program that uses NO methods, but use scanner: Write a program where you...

70.2K

Verified Solution

Question

Programming

3) Create a Java program that uses NO methods, but usescanner:

Write a program where you will enter the flying distance fromone continent to another, you will take the plane in one country,then you will enter miles per gallon and price of gallon and in theend it will calculate how much gas was spend for that distance inmiles.

Steps: 1) Prompt user to enter the name of country that youare

2) Declare variable to enter and relate to scanner.

3) Prompt user to enter the name of country where you arewilling to go.

4) Declare variable to enter and relate to scanner.

5) Create scanner, also declare variable double for distance,miles Per Gallon and price Per Gallon.

6) Prompt the user to enter data of your choice for each one ofthem

7) Create variable ticket which calculate distance divided bymultiplication of miles Per Gallon and price Per Gallon

8) Create condition that if ticket cost is less then 1000 youare flying close, if greater then 1000 and less then 5000 they areflying far, if greater then 10000 very far and son on

9) In the end display the miles from one country to another andcost of flying and how far you are flying based on conditions.

Answer & Explanation Solved by verified expert
4.2 Ratings (817 Votes)
import javautilScannerpublic class Main public static void mainString args Scanner sc new    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students