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 a butt cap? (0.5 points)
777dan777 [17]

Answer:

Butt cap chops off the stroke at the end.

Explanation:

Stroke end are called caps, other parts of a stroke are joins and dashes. There are three types of caps used in Computer graphics design, they are;

Butt cap, round cap and projecting cap.

5 0
3 years ago
What is the difference between 1080p and 2k?
professor190 [17]
They have the same  vertical resolution. I can suggest you to watch the video in youtube .<span>https://www.youtube.com/watch?v=uluEEGBHyUE</span>
7 0
3 years ago
Which of the following statements is not true? Group of answer choices
Nesterboy [21]

Answer:

A

Explanation:

Option A is not true because a Boolean variable type can hold one of two values only that is  (true/True or false/False).

All the other options given in the question are correct because

  1. A variable declaration refers to specifying its type and name
  2. If string variables are assigned a numeric values which is legal provided the values are enclosed in quaotes( " "), trying to carryout a mathematical operation like addition will result in string concatenation.
  3. The Variable name I_Love_to_eat_pizza is legal because it contains no special characters, doesn't start with a number and its not a reserved word in any language
4 0
3 years ago
The ____ criteria filter requires the records displayed to start with the specified text string
lys-0071 [83]

The "Begins With" criteria filter is what your looking for

3 0
3 years ago
The science of networking is attributed to which government's involvement?
worty [1.4K]

Answer:

The United States

if I am not mistaken

6 0
2 years ago
Other questions:
  • Host to IP address lookup and its reverse lookup option are very important network services for any size network. It is also how
    14·1 answer
  • Describe how mendeleev organized the elements into rows and columns in his periodic table.
    12·1 answer
  • The central processing unit (CPU) processes the data in a computer systenpical data processing includes:
    10·1 answer
  • Radio and television are examples of
    9·1 answer
  • Compare and contrast CD and DVD?
    10·2 answers
  • What functions do these WLAN applications and tools perform on WLANs: airmonng, airodump-ng, aircrack-ng, and aireplay-ng
    10·1 answer
  • Por que se dice que la tecnología ha tenido muchos aportes positivos para la sociedad pero también nos ha hecho dependientes de
    9·1 answer
  • What is the result when you run the following line of code after a prompt??
    5·1 answer
  • Hey guys, I don’t have a problem for you but If anyone knows do you still pass your grade level if you failed 1 class in the las
    11·2 answers
  • How many total bits are required for a direct-mapped cache with 128 blocks and a block size of 8 bytes, assuming a 4GB main memo
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!