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]
3 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]3 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]3 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
What is BINARY it is making get confused
enot [183]
It is a number that is expressed in the binary numerical system
6 0
3 years ago
When did Microsoft released MS-Word 2016? S When did Microsoft released MS - Word 2016​
Pepsi [2]

Answer:

July 9, 2015

Explanation:

It was released on macOS on July 9, 2015, and on Microsoft Windows on September 22, 2015, for Office 365 subscribers. Mainstream support ended on October 13, 2020, and extended support for most editions of Office 2016 will end on October 14, 2025, the same day as Windows 10.

3 0
2 years ago
In which scenario would someone most likely be
andrew11 [14]

Answer:

Option 1. Brent is preparing for his class speech

Explanation:

I chose option one because he would need presentation software to show his class about his speech

5 0
3 years ago
During which phase of the software development process are developers MOST likely to log bugs
sleet_krkn [62]

Answer:

The answer is the testing phase.

Explanation:

<em>Testing is the part of software development wherein developers performs test on the system to encounter bugs and possible errors before they would deploy the system. The aim of testing is to ensure that the system meets its objective (or the system perform its desired function). In any case that there is a bug or error present during the test, testers must logged it in and developers must go back to the coding stage to fix bugs they found in codes and system process.  Then testers would run series of tests again to ensure that the previous errors are gone. This will be repeatedly executed until the system is down to 0 errors before it will be introduced to the clients or desired users of the system.</em>

4 0
3 years ago
Read 2 more answers
What is alphuneric text not intended for calculation entered into a spreadsheet called?
Over [174]
It is called text or general.
7 0
3 years ago
Other questions:
  • ‘The increased availability of mobile digital devices has had a positive impact on how young people use their free time’. Make a
    14·2 answers
  • Differences between Quality of Services and a Service of Quality approach
    9·1 answer
  • Information from the system that is used to make modifications in the input, processing actions, or outputs is referred to as: G
    9·2 answers
  • Do you think the current system of punishment in the United States works? Why? What would you change?
    13·1 answer
  • Which of the following is your personal record of payments and bill-paying?
    13·1 answer
  • Write a program to complete the task given below: Ask the user to enter any 2 numbers in between 1-10 and add both of them to an
    8·1 answer
  • (Display characters) Write a method that prints characters using the following header: public static void printChars(char ch1, c
    6·2 answers
  • What is pseudo code?
    11·2 answers
  • Generally speaking, what is a “best practice"?
    13·1 answer
  • Describe who was Alan Turing in 100 words.<br> First to answer will get brainliest.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!