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
marta [7]
3 years ago
11

Write a method so that the main() code below can be replaced by simpler code that calls method calcMilesTraveled(). Original mai

n():
public class CalcMiles {
public static void main(String [] args) {
double milesPerHour = 70.0;
double minutesTraveled = 100.0;
double hoursTraveled;
double milesTraveled;
hoursTraveled = minutesTraveled / 60.0;
milesTraveled = hoursTraveled * milesPerHour;
System.out.println("Miles: " + milesTraveled);
}
}
1 import java.util.Scanner;
2
3 public class CalcMiles (
4
5 /" Your solution goes here ./
6 private double calcMilesTraveled(double milesPertour, double ninsTraveled)
7 double hoursTraveled
8 double milesTraveled;
9
10 hoursTraveled mibsTraveled 60.8
11 milesTraveled hoursTraveled milesperhour
12
13 return milesTraveled;
14
15
16 public static void main(String 0] args)
17 double milesPerhour 70.0;
18 double minutesTraveled 100.0
19
20 System.out.printin("Miles: mphAndMinutesToMiles(milesPerHour, minutesTraveled))i
Computers and Technology
1 answer:
patriot [66]3 years ago
5 0

Answer:

See explanation

Explanation:

From the question, you have answered the question. However, it is poorly formatted.

<em>So, I'll help present the code properly and also give explanation using comments.</em>

import java.util.Scanner;

public class CalcMiles{

//This line defines the calcMilesTraveled method

private static double calcMilesTraveled(double milesPerhour, double minsTraveled){

//This declares hoursTraveled

double hoursTraveled;

//This declares milesTraveled

double milesTraveled;

<em>//This calculates the hoursTraveled</em>

hoursTraveled = minsTraveled/60.0;

//This calculates the milesTraveled

milesTraveled = hoursTraveled * milesPerhour;

//This returns the milesTraveled

return milesTraveled;

}

//The main method begins here

public static void main(String [] args){

//This declares and initializes milesPerhour

double milesPerhour =70.0;

//This declares and initializes minutesTraveled

double minutesTraveled = 100.0;

//This calls the calcMilesTraveled function and also prints the required result

System.out.println("Miles: "+calcMilesTraveled(milesPerhour, minutesTraveled));

}

}

<em>See attachment for program without comments</em>

Download txt
You might be interested in
3.6 Code Practice on Edhesive
Alchen [17]

I've included my code in the picture below. Best of luck.

6 0
2 years ago
A derived class is a class that inherits data members and functions from a ____ class.
mezya [45]
The answer is superclass
6 0
3 years ago
What is printed to the console?<br> console.log(15 % 4);<br><br> 1<br><br> 2<br><br> 3<br><br> 4
Radda [10]

Answer:

3

Explanation:

7 0
2 years ago
A soft news story and a feature story are the same thing.<br> O True<br> O False<br> HELLPP ASSAAAP
bogdanovich [222]
The answer would be False!
5 0
2 years ago
Read 2 more answers
If you want to wrap text so that it fits a particular cell, which formatting section would you use?
Nataly_w [17]
<h2>Alignment section helps to wrap text in Excel</h2>

Explanation:

  • Alignment section available in Home ribbon has many option such as aligning the text to left, right, center.
  • It also has options to rotate the selected text diagonally, vertically, etc.
  • The user can also merge two or more cells and do necessary alignment
  • When it comes to wrapping the text, texts are wrapped when the count of letters exceeds the width of the cell. Excel has "Wrap text" option to wrap the word to the next line.

5 0
2 years ago
Other questions:
  • Is a network traffic management device used to connect different network segments together?
    9·1 answer
  • Which of the following is not an impact device?<br> Joy Stick<br> Track Ball<br> Mouse<br> Printer
    10·1 answer
  • TRUE OR FALSE: Individuals involved in surveillance prior to a terrorist attack are always well-trained and equipped.
    13·1 answer
  • Graphs and charts are two different elements. True or False
    15·1 answer
  • Georgenotfound??? question mark??
    15·2 answers
  • _ models are non visual ways of communicating how someone thinks about something in the natural world
    12·1 answer
  • Computers help eliminate the repetitiveness of manual tasks. How can this benefit you in your overall career?
    9·2 answers
  • Which cable would you check if you can't access any web pages?
    12·1 answer
  • how risk can impact each of the seven domains of a typical IT infrastructure: User, Workstation, Local Area Network (LAN), Local
    7·1 answer
  • Lab 8-1: Working with Boot Loader and Runlevels what is the root password
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!