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
stealth61 [152]
3 years ago
9

Write a line of code to convert time to hours. Remember there are 60 minutes in an hour. Then write a line of code to calculate

the speed of each runner in miles per hour. Speed is distance divided by time.
Computers and Technology
2 answers:
Rudik [331]3 years ago
8 0

Answer:

int giventime;

float timetohours, distance, speed;

timetohours = giventime/60;

speed = distance/timetohours;

Explanation:

The steps to achieving the above solution are as follows:

1. Determine a name for the variables that will hold the values of each entity

2. Determine the data type of the variables in step 1

3. Declare the variables and their respective datatypes

4. perform the mathematical operations as requested

Before I explain in further the steps 1-4, let me define some key words.

<u></u>

1. <u>VARIABLE</u>: a variable in programming is where data/information can be stored. Usually variables are given distinct and unique names that depict what they store in a  wat. From the solution above, we have 4 variables:

  • giventime: this is the time that is given, this is the time that should be converted into hours(as stated in the question)
  • timetohours: this variable will hold the value of the converted giventime above to hours.
  • distance: this variable will hold the value of the distance that is known. This value will be given to us, which is one of the 2 parameters that will be used to calculate the speed.
  • Speed: this variable holds the value of the calculated speed. That is: distance divided by time.

2.  <u>DATATYPE: </u>A Since a variable can hold data,  we have to also determine what type of data such a variable is holding. Is the data a whole number? decimal? date format? string of characters? e.t.c. This determination of what kind of data is being held within a variable is called datatype. There are several classifications of Data(datatypes) but in this example we used 2 types. Let us define them:

  • Int: "int" is the short form for Integer. An integer datatype is a datatype classification for whole numbers that do not have any decimal place. Example 1, 200, 20000, 30000, are all integers, but 12.1 is not an integer.
  • float: a float datatype is a datatype that has a decimal place. Example of floats include 12.33, 0.2, 1.44 and so on.

Now lets go ahead to explain the steps we took in achieving the solution:

1. We determined the variable names to be used. From the question we know that we will need the following details:  

time that will be converted,

the result of the conversion,

the distance and also

the resulting speed. We created 4 variables for each of these parameter.

2 Determining the variable datatype is another task. first we know that time is given in whole numbers(if not converted to hours yet, example: 20minutes, 33minutes, 46minutes and so on), so giventime will be an integer(int), however the converted time might not be a whole number, example 33 minutes will be 0.55hours. This number has a decimal place and thus we define the converted time(timetohours) as a float datatype. After that we have speed variable, we are not sure of what the resulting speed will be, however, since one of the parameters(time) that will be used to calculate the speed is already a Float datatype, there is a high tendency that the resulting value of speed will also be a float. In the light of this, we declare variable speed as float datatype. Next is the Distance, We do not know what value we will be given for the distance, so we make it open. Just in case we are not given an integer, thus distance datatype is set to float as well.

3. For the code to work, and the computer to understand our variables, we have to declare each of the variables that we have created. Declaring the variable simply means writing the variable's data type just before writing the variable. Example int giventime, float speed. In the first case, int is the datatype and the variable of datatype int is "giventime" , and in the second instance, float is the datatype andthe variable with this datatype is "speed"

4. Performing the mathematical operation:  

  • The first operation is converting the given time to hours. To get the corresponding hours for any given time, we simply divide the time by 60 to make an hour. Thus we have giventime/60 this will give us the resulting time in hours.
  • Second mathematical operation is calculating the speed: we have already been informed from the question, that speed is distance divided by time, so we divide the distance variable by the timetohours variable(the time which we have converted to hours) which gives us : distance/timetohours
DaniilM [7]3 years ago
5 0

Answer:

float time_hourly=(time_min/60);

float speed_mph=(distance_mil/time_hourly);

Explanation:

I have taken a float variable time_hourly to convert the time given in minutes in hours.We need to divide the time in minutes by sixty since there are 60 minutes in an hour.

I have taken a float variable speed_mph to calculate the speed.Since we know the speed is distance/time and provided the distance is in miles and the time is in hours.

You might be interested in
You have an application that you would like to run on your Windows workstation every Monday at 3:00 p.m. Which tool would you us
NikAS [45]

Answer:

Task Scheduler

Explanation:

Task Scheduler allows you to automate tasks in Windows 10

7 0
3 years ago
To create a multi-column and multi-row box for users to type into in an html form, use the ____________ tag pair
alexgriva [62]

To create a multi-column and multi-row box for users to type into in an html form, use the <textarea></textarea> tag pair.

<span>The html tags are the codes or the hidden keywords in the web browser to tell about its format and displayed content. The html tags mostly comes in pairs, pair consist of the start tag and end tag.</span>
4 0
3 years ago
Ith what frequency do balance changes happen in the game?​
Akimi4 [234]
What game ? I’m not sure what ur trying to ask
8 0
3 years ago
Read 2 more answers
A medium-sized highway construction company CST has chosen to constrain its investment in computing resources to laptop and desk
Valentin [98]

Answer:

The service model employed for the data storage capability of only CST is:

SaaS (Software as a Service).

Explanation:

The three cloud computing categories are Infrastructure as a Service (IaaS), Software as a Service (SaaS), and Platform as a Service (PaaS).  The three cloud computing services provide different virtual computing resources.  In the case of CST, it utilizes only the data storage software of a provider, who provides the data storage infrastructure, including cloud-based servers, while CST uses its own "laptop and desktop computers and other networking hardware and software to access the Internet efficiently."

5 0
2 years ago
An employee at a branch office is creating a quote for a customer. In order to do this, the employee needs to access confidentia
SOVA2 [1]

The employee would access an intranet to maintain security.

6 0
3 years ago
Other questions:
  • Where is the insert function button found in microsoft excel?
    11·1 answer
  • Use the RSA cipher with public key n = 713 = 23 · 31 and e = 43. Encode the word "KING" into its numeric equivalent and encrypt
    15·1 answer
  • 1. Which of the following should NOT be in a tagline?
    12·1 answer
  • Chuck plans to go on a hiking trip. Before the hiking trip, Chuck's bank account has $129.50. He then spends $129.50 on hiking g
    6·1 answer
  • What is the primary limitation of free versions of antivirus applications?
    13·1 answer
  • Using Python I need to Prompt the user to enter in a numerical score for a Math Class. The numerical score should be between 0 a
    7·1 answer
  • Write a program that reads a list of integers into a vector, and outputs the two smallest integers in the list, in ascending ord
    5·1 answer
  • Blank Are input instructions you give to a computer
    13·1 answer
  • The faster an object is moving, the ________ the shutter speed needs to be in order to freeze motion.
    10·2 answers
  • Computer system with a 32-bit logical address and 4k-byte page size. assume that each entry of a page table consists of 4bytes.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!