Question

In: Computer Science

In each of the projects that follow, you should write a program that contains an introductory...

In each of the projects that follow, you should write a program that contains an introductory docstring. This documentation should describe what the program will do (analysis) and how it will do it (design the program in the form of a pseudocode algorithm). Include suitable prompts for all inputs, and label all outputs appropri- ately. After you have coded a program, be sure to test it with a reasonable set of legitimate inputs.

Q. Write a program that takes as input a number of kilometers and prints the corresponding number of nautical miles. Use the following 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.

*please use IDLE( python 3.7)

Solutions

Expert Solution

SOURCE CODE:

*Please follow the comments to better understand the code.

**Please look at the Screenshot below and use this code to copy-paste.

***The code in the below screenshot is neatly indented for better understanding.




def km_to_nautical_miles(kilometers):
    """
    THIS METHOD WILL TAKE THE kilometers PARAMETER AND CALCULATE THE NAUTICAL
    MILES OF THE KILOMETERS as kilometers*(5400/10000)
    :param kilometers:A float value that represents the number of kilometers
    :return: The calculated nautical_miles value
    """
    nautical_miles = kilometers
    nautical_miles /= 10000  ##  North Pole and Equator distance in Kilometers
    nautical_miles *= 90     ##  90 degrees between North Pole and Equator
    nautical_miles *= 60     ## 60 minutes of arc per degree

    return nautical_miles


km = float(input("Number of kilometers: "))
num_nautical_miles = km_to_nautical_miles(km)

print(km, 'kilometers is equal to ', num_nautical_miles, " nautical miles")

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

SCREENSHOT:


Related Solutions

AskInfoPrintInfo Write a program called AskInfoPrintInfo. It should contain a class called AskInfoPrintInfo that contains the...
AskInfoPrintInfo Write a program called AskInfoPrintInfo. It should contain a class called AskInfoPrintInfo that contains the method main. The program should ask for information from the user and then print it. Look at the examples below and write your program so it produces the same input/output. Examples (the input from the user is in bold face) % java AskInfoPrintInfo enter your name: jon doe enter your address (first line): 23 infinite loop lane enter your address (second line): los angeles,...
Write a lex program that can identify each of the following tokens. The program should produce...
Write a lex program that can identify each of the following tokens. The program should produce a line for each token where the first word is token itself followed by the token type. • Identifiers: name of variables and functions (identifier name should be started by a letter followed by letters or digits and maximum eight characters in length). • Keywords: if, then, else, for, while, do, switch, case etc. • Numbers: integer, float (float number format that supports in...
You should write a small C++ program that performs the following tasks: First, your program should...
You should write a small C++ program that performs the following tasks: First, your program should read in a set of 5 integers from “standard in” (remember cin). The numbers that you read in will be either zero or positive. If at least one of the five numbers entered is non-zero then your program should calculate the sum of the numbers and report that back to the user using “standard output” (remember cout). Then your program should be ready to...
In this problem, you will write a program that reverses a linked list. Your program should...
In this problem, you will write a program that reverses a linked list. Your program should take as input a space-separated list of integers representing the original list, and output a space-separated list of integers representing the reversed list. Your algorithm must have a worst-case run- time in O(n) and a worst-case space complexity of O(1) beyond the input. For example, if our input is: 5 7 1 2 3 then we should print: 3 2 1 7 5 Please...
Write a program in C++ (parking.cc) that reads a group of input lines. Each line contains...
Write a program in C++ (parking.cc) that reads a group of input lines. Each line contains an A for arrival or a D for departure, which is terminated by a :, and a license plate number, which is terminated by a :. The program should print a message each time a car arrives or departs. When a car arrives, the message should specify when the garage is full. If there is no room for a car, the car simply leaves....
XML and JAVA Write a Java program that meets these requirements. It is important you follow...
XML and JAVA Write a Java program that meets these requirements. It is important you follow these requirements closely. • Create a NetBeans project named LastnameAssign1. Change Lastname to your last name. For example, my project would be named NicholsonAssign1. • In the Java file, print a welcome message that includes your full name. • The program should prompt for an XML filename to write to o The filename entered must end with .xml and have at least one letter...
You should use Visual Studio to write and test the program from this problem.   Write a...
You should use Visual Studio to write and test the program from this problem.   Write a complete program with a for loop that (5 pts) uses proper variable types. (10 pts) uses a for loop to read in a real numbers exactly 8 times (10 pts) adds the number read in the loop to a running sum. (10 pts) Computes the average of the 8 numbers as a real number. (5 pts) Prints the correct result with 2 decimal places,...
what are the 10 steps you think student should follow to write a paper at doctoral...
what are the 10 steps you think student should follow to write a paper at doctoral level
Write a program that implements the follow disk scheduling algorithms. You can use C or Java...
Write a program that implements the follow disk scheduling algorithms. You can use C or Java for this assignment. FCFS SSTF SCAN C-SCAN LOOK C-LOOK Your program will service a disk with 5000 cylinders (numbered 0 to 4999). Your program will generate a random initial disk head position, as well as a random series of 1000 cylinder requests, and service them using each of the 6 algorithms listed above. Your program will report the total amount of head movement required...
Write a program that contains a function that takes in three arguments and then calculates the...
Write a program that contains a function that takes in three arguments and then calculates the cost of an order. The output can be either returned to the program or as a side effect. 1. Ask the user via prompt for the products name, price, and quantity that you want to order. 2. Send these values into the function. 3. Check the input to make sure the user entered all of the values. If they did not, or they used...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT