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
astraxan [27]
3 years ago
9

Write a program that takes as input a number of kilometers and prints the corresponding number of nautical miles. Use the follow

ing approximations: A kilometer represents 1/10,000 of the distance between the North Pole and the equator. There are 90 degrees, containing 60 minutes of arc each, between the North Pole and the equator. A nautical mile is 1 minute of an arc.
Computers and Technology
1 answer:
Dmitrij [34]3 years ago
8 0
<h2>Answer:</h2>

import java.util.Scanner;

public class NauticalMiles{

   public static void main (String [ ] args){

      Scanner input = new Scanner(System.in);

      System.out.println("Please enter the number of kilometers");

      double km = input.nextDouble();

      double nm = 0.54 * km;

      System.out.println("The corresponding number of nautical miles is "  + nm);

    }

}

<h2>Explanation:</h2><h2></h2>

<em>1 => Pre-code analysis</em>

According to the question,

(a) <em>A nautical mile (nm) is 1 minute of an arc.</em>

=> 1 nm = 1 minute of an arc

(b)<em>There are 90 degrees, each containing 60 minutes of arc, between the North pole and the equator.</em>

=> Each of the degrees in 90 degrees has 60 minutes of arc

=> 1^{0} = 60 minutes of arc

=> 90^{0} = 90 x 60 minutes of arc

=> 90^{0} = 5400 minutes of arc

(c) <em>A kilometer (km) represents 1/10,000 of the distance between the North pole and the equator. </em>

=> A kilometer = (1 / 10000) x distance between the North pole and equator.

Remember that the distance between the North pole and the equator as shown in (b) above is 90 degrees which is equal to 5400 minutes of arc.

=> 1 km = (1 / 10000) x 5400 minutes of arc

=> 1 km = (1 / 10000) x 5400 x 1 minute of arc

As shown in (a) above, 1 minute of arc is 1 nautical mile(nm).

=> 1 km = (1 / 10000) x 5400 x 1 nm

<em>=> 1 km = 0.54 nm.</em>

=========================================================

<em>2 => The code analysis</em>

The code has been written in Java.

The following is the line-by-line explanation of the code written as comments.

// Import the scanner class to allow for user's inputs

import java.util.Scanner;

// Declare the main class to hold and run the application

public class NauticalMiles {

   // Write the main method where execution will begin

   public static void main (String [ ] args) {

      // Create an object <em>input </em>of the Scanner class  

      Scanner input = new Scanner(System.in);

     

      // Prompt the user to enter the number of kilometers

      System.out.println("Please enter the number of kilometers");

      // Store the user's input in a double variable called <em>km</em>

      double km = input.nextDouble();

      // Convert the input to nautical miles using the formula from the

      // pre-code analysis above. i.e 1km = 0.54nm.

      // Store the result in a double variable called <em>nm</em>

      double nm = 0.54 * km;

      // Print out the result (the nautical mile)

      System.out.println("The corresponding number of nautical miles is "  + nm);

    }       // End of main method

}            // End of class declaration

=========================================================

<em>3 => Sample output</em>

<em></em>

> Please enter the number of kilometers

>> <em>45</em>

> The corresponding number of nautical miles is 24.3

You might be interested in
13. Which Windows feature allows users to control software operations by clicking and pointing with a mouse?
Thepotemich [5.8K]
The correct answer is option D.
i.e. graphic user interface allows users to control software operations by clicking and pointing with a mouse.

GUI is a type of interface that allows the user to interact through computer graphics.
8 0
3 years ago
Identify the following verb by number and person by checking on the appropriate boxes.
Makovka662 [10]
Second person ig Imao yeah
3 0
2 years ago
Read 2 more answers
Salim wants to add a device to a network that will send data from a computer to a printer. Which hardware component should he us
balandron [24]
It’s letter B good luck
4 0
3 years ago
Read 2 more answers
Put the following events from computer history in the order they happened:
kykrilka [37]
Show us a picture so we can answer
7 0
3 years ago
Nothin to see here just browsin
velikii [3]

Answer:

What????

What does that mean??????????????????????????????????

4 0
3 years ago
Other questions:
  • The open items on your computer are displayed here. menu bar open bar taskbar toolbar
    15·2 answers
  • The ease of travel in the twentieth century played a role in the advancement of medicine. Based on this lesson, which statement
    5·2 answers
  • Which button would you use to quickly add addresses to a mail merge envelope?
    5·1 answer
  • State three differences between a hard drive and a pen drive​
    6·1 answer
  • What's the name of this apex legend hero​
    13·2 answers
  • What can search the internet and select elements based on important words
    10·1 answer
  • each term to the appropriate definition. DBMS data mining hash file index key field locking protocol relation roll back schema S
    14·1 answer
  • Suppose that a is declared as an int a[99]. Give the contents of the array after the following two statements are executed: for
    15·1 answer
  • Why was the Internet first developed? Use details and information to explain your answer.
    6·1 answer
  • Can i get any information on this website i'd like to know what its for ?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!