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 are the benefits of using a multiview sketch to communicate a design?
maks197457 [2]
There are three dimensions of an object-- the top, the front, and the side views. A Multiview sketch shows two or three views of an object. Multiview sketch gives the shape description of the object. It also serves as the main form of communication between manufacturers and sketchers. 
6 0
3 years ago
Pls need this asap
Inga [223]

Answer: I dont know my computer or any of that all I know is that it is a dell

Explanation:

8 0
1 year ago
Read 2 more answers
0.005098 megaliters to liters. record your answer in whole liters
Dmitriy789 [7]
Your answer would be 5098 liters.

Reason being, because there are 1,000,000 liters in one megalitre, so you just multiply 0.005098 by 1,000,000 to get your answer of 5098 liters.
6 0
2 years ago
For which tasks is Layout view most helpful? Check all that apply.
Solnce55 [7]

The task where the Layout view most helpful is showing how a report will look when printed.

<h3>What is the Layout view?</h3>

The Layout view is known to be a view that is said to be more of visually-oriented when compared to the Design view.

Note that the Layout view is one where each control often shows real data and as such, The task where the Layout view most helpful is showing how a report will look when printed.

Learn more about  Layout view  from

brainly.com/question/1327497

#SPJ1

6 0
1 year ago
Select the correct answer.
Softa [21]

Answer:

D. smart phone

explanation;

a. what the heck is a radio going to do?

b. an HD television? is his job watching movies?

d. he already has a form of communication he uses, he needs something that can to both things at the same time

c. a smart phone can do everything he needs to do, likely faster than a landline phone or laptop.

5 0
2 years ago
Other questions:
  • Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A[
    13·1 answer
  • _____ is defined as an attraction for a source based on a resemblance between the source and receiver of a message.
    15·1 answer
  • Are headphones considered a computer? Why or why not?
    13·2 answers
  • Insert a function in cell g5 to calculate the first student's monthly payment, using appropriate relative and absolute cell refe
    13·1 answer
  • Create a structure named planet This structure will contain distance from Earth as an integer Atmosphere, language, people and p
    8·1 answer
  • Anna’s computer will not power on. What aspect of the computer should Anna check (hardware or software)? How can Anna work to re
    5·1 answer
  • Consider the following code segment.
    15·1 answer
  • When including multiple images in a report, it may help to create a _____ on each image so you can cross reference them througho
    11·1 answer
  • All of the following are examples of being computer literate, EXCEPT ________. Group of answer choices knowing how to build and
    7·1 answer
  • Which of these programmers creates the core game engine?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!