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
Ket [755]
2 years ago
11

Write a program to display MPH (Miles per Hour). Create a function to calculate the MPH. Ask the user for the number of miles dr

iven and the number of minute it took to drive that many miles. Validate that both the number of miles and the number of minutes is a positive, non-zero number. Pass both the number of miles and the number of minutes to the function, and have the function return the MPH.
Computers and Technology
1 answer:
puteri [66]2 years ago
7 0

Answer:

In Python:

def MPH(miles,minutes):

   mph = round(60 * miles/minutes,1)

   return mph

   

miles = float(input("Miles: "))

minutes = float(input("Minutes: "))

if miles>0 and minutes>0:

   print("MPH: ",MPH(miles,minutes))

else:

   print("Positive inputs only")

Explanation:

This defines the function

def MPH(miles,minutes):

This calculates mph rounded to 1 decimal place

   mph = round(60 * miles/minutes,1)

This returns the calculated mph

   return mph

The main begins here

This gets input for miles    

miles = float(input("Miles: "))

This gets input for minutes

minutes = float(input("Minutes: "))

If miles and minutes are positive

if miles>0 and minutes>0:

This calls the MPH function

   print("MPH: ",MPH(miles,minutes))

If otherwise, this prompts the user for positive inputs

<em>else:</em>

<em>    print("Positive inputs only")</em>

You might be interested in
Which type of programmer designs programs for applications executed on the internet?
lisabon 2012 [21]
Wait. What? What does that even mean?
8 0
3 years ago
Respond to the following in three to five sentences. Select one netiquette guideline. Explain how this helps you draft more effe
slamgirl [31]

Answer:

Keeping as few emoji's as possible. This helps because lots of emoji's can make things confusing and/or annoying. This just means being kind to the person you're messaging and not making things confusing.

8 0
3 years ago
Please solve in 5 mins very fast​
Dmitriy789 [7]

Answer:

a. virtual reality

b. Master Boot Records

c. Primary function of a router

d. zoom

Explanation:

4 0
3 years ago
Read 2 more answers
Does C supports STRINGS as a data type?
Nat2105 [25]

Answer:

C language does not support strings as a data type. A string is actually one-dimensional array of characters in C language. These are often used to create meaningful and readable programs.

Explanation:

6 0
1 year ago
A variable like userNum can store a value like an integer. Extend the given program to print userNum values as indicated.(1) Out
dimulka [17.4K]

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 int userNum;

 Scanner input = new Scanner(System.in);

 System.out.print("Enter integer: ");

 userNum = input.nextInt();

 System.out.println("You entered "+userNum);

 System.out.println(userNum+" squared is "+(userNum*userNum));

 System.out.println(userNum+" cubed is "+(userNum*userNum*userNum));

 int userNum2;

 System.out.print("Enter another integer: ");

 userNum2 = input.nextInt();

 int sum= userNum + userNum2; int product = userNum2 * userNum;

 System.out.println(userNum+" + "+userNum2+" = "+sum);

 System.out.println(userNum+" * "+userNum2+" = "+product); } }

Explanation:

This declares userNum

 int userNum;

 Scanner input = new Scanner(System.in);

This prompts the user for input

 System.out.print("Enter integer: ");

This gets user input from the user

 userNum = input.nextInt();

Number (1) is implemented here

 System.out.println("You entered "+userNum);

Number (2) is implemented here

 System.out.println(userNum+" squared is "+(userNum*userNum));

 System.out.println(userNum+" cubed is "+(userNum*userNum*userNum));

This declares another variable userNum2

 int userNum2;

This prompts the user for another input

 System.out.print("Enter another integer: ");

This gets user input from the user

 userNum2 = input.nextInt();

This calculates the sum and the product

 int sum= userNum + userNum2; int product = userNum2 * userNum;

Number (3) is implemented here

 System.out.println(userNum+" + "+userNum2+" = "+sum);

 System.out.println(userNum+" * "+userNum2+" = "+product);

8 0
2 years ago
Other questions:
  • What is the equivalent of film speed in digital cameras?
    6·2 answers
  • What file would you edit to restrict the number of simultaneous logins a user can employ??
    14·1 answer
  • I dopped my Fujifilm Instax mini 8 and now the case won't close and it takes blank pictures can anyone tell me what to do, pleas
    6·2 answers
  • A user has been given Full Control permission to a shared folder. The user has been given Modify permission at the NTFS level to
    11·1 answer
  • You can tell a cell is the active cell when it has a
    14·2 answers
  • no one can succeed in his or her career without relying on others for help or opportunities. It’s best, though,
    13·1 answer
  • Which of the following is most likely to be considered plagiarism? Using materials from a source without proper citation. Adding
    5·1 answer
  • What is Java Script?
    13·1 answer
  • Help me pls, thank you
    12·2 answers
  • What is the answer ????​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!