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
Nonamiya [84]
2 years ago
14

Write a method so that the main() code below can be replaced by the simpler code that calls method mphandminutestomiles(). origi

nal main():
Computers and Technology
2 answers:
aliya0001 [1]2 years ago
6 0
Create the function as a double. Put both your variables to call inside the () of the created function. Then create a variable to hold the answer. 

double MphAndMinutesToMiles(double milesPerHour, double minutesTraveled){ double miles;  miles = (minutesTraveled / 60) * milesPerHour;  return miles;}
lara [203]2 years ago
5 0

The simpler code for the given main ( ) function is shown below. For this, calculate the hours and miles before the main function and store them in the separate variables and after this, use these variables in main ( ) code. The below complete code is written in Java which  reduce the given main ( ) code and also make it simple.

Further Explaination:

The simple code in Java to calculate the miles traveled is shown below:

Code: Simple.java

import java.util.Scanner;

public class CalcMiles

{

//Define the method calcMilesTraveled().

Public double calcMilesTraveled (double mph, double minutesTravelled)

{

//Declare required variables.

Double hoursTravelled = 0.0;

Double milesTravelled = 0.0;

//Calculate the hours travelled and miles travelled.

hoursTravelled = minutesTravelled / 60.0;

milesTravelled = hoursTravelled * mph;

//The total miles travelled in return.

Return milesTravelled;

}

public static void main(String [] args)

{

double milesPerHour = 70.0;

double minsTravelled = 100.0;

CalcMiles tripCalculator = new CalcMiles();

System.out.println("Miles: " + tripCalculator.calcMilesTraveled (milesPerHour, minsTraveled));

}

}

Output:

Run the program, the output will be look like as below:

Miles: 116.66666666666667

Learn more:

1. A company that allows you to license software monthly to use online is an example of ? brainly.com/question/10410011  

2. How does coding work on computers?  brainly.com/question/2257971  

Answer details:

Grade: College Engineering

Subject: Computer Science and Engineering

Chapter: Java Programming

Keyword:

Java, input, output, programming, statements,  class, double, int, miles, hours, milesPerHour, hoursTraveled, printf, return

You might be interested in
Which pillar in the cisco iot system describes embedded networks that include compact form factor switch and router cards runnin
kolezko [41]
<span>The network connectivity pillar in the Cisco IoT system describes embedded networks that include compact form factor switch and router cards running Cisco IOS software to provide secure data, voice, and video communications.
</span>The network connectivity is one of the six pillars <span>supporting Cisco's IoT system. It </span>includes purpose-built routing, switching and wireless products;
8 0
3 years ago
pleeeease help!! I tried to turn on icloud photos to save storage and it’s been stuck at 1%. does anyone know why or how to fix
gtnhenbr [62]

Answer:

Explanation:

It just takes a very long time if you have too many videos or even very long ones. It took me 14 hours to download mine. You have to let it download though do not interrupt it! Very important!

3 0
3 years ago
Which form of data does the image represent? (10 points)<br> A. Analog data<br> B. Digital data
EastWind [94]
The image in the photograph is representing A. Analog Data. Analog data is data that is represented in a physical way. Where digital data is a set of individual symbols, analog data is stored in physical media, whether that's the surface grooves on a vinyl record, the magnetic tape of a VCR cassette, or other non-digital media. Analog and digital signals are different types which are mainly used to carry the data from one apparatus to another. Analog signals are continuous wave signals that change with time period whereas digital is a discrete signal is a nature. Examples of analog technology: photocopiers. old land-line telephones. audio tapes. old televisions (intensity and color information per scan line). Analog and digital signals are the types of signals carrying information. The major difference between both signals is that the analog signals that have continuous electrical signals, while digital signals have non-continuous electrical signals.
8 0
2 years ago
Presentation software allows you to display information in the form of a slide show. Which is NOT a presentation application?
saul85 [17]
Access is a database management system, thus it is not a presentation application.
3 0
2 years ago
An organization has opened a new office in a somewhat risky neighborhood. The office manager installs a CCTV system to monitor t
lorasvet [3.4K]

Answer:

Option A i.e., Detective.

Explanation:

When an organization, in a very bad area, recently started a new office. The manager installs a CCTV device for 24-hour surveillance of the area and entrance. So, the following scenario is about the detective control because If users start understanding that their actions are registered and tracked through authenticating into the computer to execute a function.

5 0
3 years ago
Other questions:
  • Please help!! will fan and medal
    12·2 answers
  • WHICH OF THESE IS A TYPE OF ETHERNET <br> 802.11AC <br> 1000BASET <br> 4G
    7·1 answer
  • An Internet Service Provider (ISP) is a company that builds the routers and wired connections that allow individuals to access t
    12·2 answers
  • You recently upgraded your computer and added an extra 512 MB of RAM. Consequently, you want to increase your swap space by addi
    10·1 answer
  • When Russ opened a website on his browser, he saw an error that the site was not compatible with the browser version he was runn
    9·1 answer
  • So I was looking at my profile and it says i'm a brainly PLUS member didn't sign up for it tho. Any ideas why this could have ha
    14·2 answers
  • Distinguish between the savings and investment options.
    8·1 answer
  • What would a bar graph best be used for? State why and give 2-3 examples of things you could demonstrate with a bar graph
    5·1 answer
  • Which of the following screen elements is a horizontal bar that displays at the
    8·1 answer
  • 7+9 help me pleas i dont know help now
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!