If you are driving across the border into Canada, it is difficult with the road signs in KPHvalues. In Canada, the Kilometers Per Hour scale is used to measure speed. In the USA, theMiles Per Hour scale is used. For example, a speed limit of 50 MPH in Vermont is 80.47 KPHin Montreal. A speed limit of 60 KPH in Toronto is 37.28 MPH in Buffalo, NY. You’d likeyour computer or smartphone to convert between the Speed limit signs so you do not get aticket.

Question
Asked Oct 20, 2019

If you are driving across the border into Canada, it is difficult with the road signs in KPH
values. In Canada, the Kilometers Per Hour scale is used to measure speed. In the USA, the
Miles Per Hour scale is used. For example, a speed limit of 50 MPH in Vermont is 80.47 KPH
in Montreal. A speed limit of 60 KPH in Toronto is 37.28 MPH in Buffalo, NY. You’d like
your computer or smartphone to convert between the Speed limit signs so you do not get a
ticket.

check_circleExpert Solution
Step 1

Algorithm-

START

Step1: Import the essential headers.

Step2: Define a class Conversion.

Step3: Define the main method for the class.

Step4: Define all the variables used in the program and mention their data types accordingly.

Step5: Perform the operations on variable.

Step6: Print the final speed conversion.

EXIT

 

Step 2

Code (in Java)-

import java.util.Scanner;

public class Conversion

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

int choice = 0;

System.out.println("Which speed conversion do you want?");

System.out.println("Enter 0 from KPH to MPH");

System.out.println("Enter 1 from MPH to KPH");

while (choice != 1 || choice != 0)

{

choice=sc.nextInt();

if (choice == 1 || choice == 0)

{

break;

}

System.out.println("Wrong Choice");

System.out.println("Please enter the correct choice: ");

}

//conversion from Kph to Mph

if(choice==0)

{

System.out.println("Enter the value of sp...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour*

See Solution
*Response times may vary by subject and question
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: PLEASE EXPLAIN ALL STEPSDraw (hand draw or using an online tool) the circuit diagrams that correspon...

A: The circuit diagrams that correspond to the following Boolean equations  drawed using an online tool...

question_answer

Q: I need help with this C++ problem.    Assume that a binary search function is searching for a value ...

A: Binary search: - It is a technique used to search an element in a sorted array.It is also known as h...

question_answer

Q: 4.7: Time Machine Your time machine is capable of going forward in time up to 24 hours. The machine ...

A: Following is the c++ program:Variables used:startHours, startMins are used to store the starting tim...

question_answer

Q: please just help with parts afterr //     3) Write friend function for the following class to overlo...

A: A friend function is defined outside the context of a class, but it has the rights to access the mem...

question_answer

Q: Question 9: Consider the following: Class Course { protected: long CRN public: Course( long c ); }; ...

A: Paste all the code module after appropriate commented area.For example://write the Default construct...

question_answer

Q: Let F = (V; A) be a digraph. Show that if u is k-edge-connected to v and v is k-edge-connected to w,...

A: Connectivity:To measure the connectedness of a digraph ‘F’, consider the minimum number of vertices ...

question_answer

Q: PLEASE EXPLAIN ALL STEPS: simplify the boolean equations: xz + (xy + ~z) ~xyz + yz + x~y

A: 1)xz + (xy + ~z)For simplifying the Boolean expression, use Karnaugh Map and follow the below steps-...

question_answer

Q: Python 3.7.4 Use the file object output to write the string "3.14159" to a file called pi.

A: Following is the program code which writes the string "3.14159" to a file called pi.To open a file c...

question_answer

Q: write a program in c++. You work for a box company, and have been asked to write a program to compar...

A: Note:The C++ program is written as per the given requirements.The code is well commented for better ...