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
dmitriy555 [2]
3 years ago
6

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

nal main():
public class CalcMiles {
public static void main(String [] args) {
double milesPerHour;
double minutesTraveled;
double hoursTraveled;
double milesTraveled;
milesPrHour = scnr.nextDouble();
minutesTraveled = scnr.nextDouble();
hoursTraveled = minutesTraveled / 60.0;
milesTraveled = hoursTraveled * milesPerHour;
System.out.println("Miles: " + milesTraveled);
}
}
import java.util.Scanner;
public class CalcMiles {
/* Your solution goes here */
public static void main(String [] args) {
Scanner scnr = new Scanner(System.in);
double milesPerHour;
double minutesTraveled;
milesPerHour = scnr.nextDouble();
minutesTraveled = scnr.nextDouble();
System.out.println("Miles: " + mphAndMinutesToMiles(milesPerHour, minutesTraveled));
}
}

Computers and Technology
2 answers:
Burka [1]3 years ago
8 0

Answer:

public static double mphAndMinutesToMiles(double m,double t){

return m*t/60;

}

Explanation:

defon3 years ago
5 0

ANSWER

The JAVA program after simplification is as below.

import java.util.Scanner;

public class CalcMiles {

   

   // variables declaration

   static double milesPerHour;

   static double minutesTraveled;      

   static double hoursTraveled;

   static double milesTraveled;

   

   // method declared static

   public static void mphAndMinutesToMiles(double speed, double mins)

   {

       // computations to calculate distance travelled

       hoursTraveled = mins / 60.0;

       milesTraveled = hoursTraveled * speed;

       

       // result displayed on the screen  

     System.out.println("Miles: " + milesTraveled);

   }

   

   // Scanner object created inside main()

   // user input taken inside main()

   public static void main(String [] args)

   {

       Scanner scnr = new Scanner(System.in);

       System.out.println("Enter miles travelled per hour ");

       milesPerHour = scnr.nextDouble();

       System.out.println("Enter minutes required to travel ");

       minutesTraveled = scnr.nextDouble();

       

       mphAndMinutesToMiles(milesPerHour, minutesTraveled);

       

   }

}

OUTPUT

Enter miles travelled per hour  

2.3

Enter minutes required to travel  

1234

Miles: 47.30333333333333

EXPLANATION

The program is simplified as explained below.

1. User input is taken using the object of Scanner class.

2. This object of Scanner class can only be created inside main() method hence, user input can only be taken inside main().

3. The code to calculate the result is separated in another method, mphAndMinutesToMiles(). This method is declared with return type void since no value is returned.

4. After user input is taken in main() for miles travelled per hour and minutes required to travel, these values are passed as parameters to the mphAndMinutesToMiles() method.

5. These parameters are used in calculation part. The total miles travelled in total hours (obtained from minutes), is calculated. The code to display the result is added to this method.

6. Inside the main method, only the code to create Scanner object, code to take user input for two variables and code to call the mphAndMinutesToMiles() is included.

7. The variables are declared as static and declared at class level.

8. No variable is declared inside any of the two methods.

You might be interested in
________ was one of the first uses of the Internet
NeTakaya

Government weapon in cold war

3 0
3 years ago
Read 2 more answers
The ________ option contains the formatting and placeholders for all of the items that appear on a side.
densk [106]

Answer:

Slide Layout contains the formatting and placeholders for all items that appear on a slide.

Explanation:

Slide Layout:

Slide layout option in MS PowerPoint contains formatting, placeholders boxes and positioning for all the content that you put on a slide.

Slide layout option allows you to format the contents, insert placeholders boxes for contents such as text or images and do their positioning as you want to appear on a slide. Placeholders are the dotted line containers that hold the content such as title, body text, tables, smart art graphics, charts, pictures, videos, clip art, and sounds.

Slide layout also contains the fonts, effects, colors, and the background (all these collectively known as the theme) of a slide.

However, PowerPoint includes a built-in slide layout, and you can modify these layout on your slide according to your specific needs. Furthermore, you can share your customized slide layout with other people who want to create a PowerPoint presentation.

In addition to, you can built-in standard slide layout in PowerPoint in the Slide-Master View.

If you created the slide, and you want to customize that slide according to specific requirement then you have the option to apply the built-in standard layout on that slide to save the time. Because it is a much easy and time-saving task instead of customizing your own slide from scratch such as making aligning and positioning the contents on the slide

6 0
3 years ago
Define undo and redo​
Varvara68 [4.7K]

The undo function is used to reverse a mistake, such as deleting the wrong word in a sentence. The redo function restores any actions that were previously undone using an undo. ... For example, if you typed a word, and then deleted it using an undo, the redo function would restore the word you delete

What do you mean by redo?

: to do (something) again especially in order to do it better. : to change (something, such as a room or part of a room) so that it looks new or different. See the full definition for redo in the English Language Learners Dictionary.

<em>What is Undo ?</em>

<em>What is Undo ?Undo is an interaction technique which is implemented in many computer programs. It erases the last change done to the document, reverting it to an older state. In some more advanced programs, such as graphic processing, undo will negate the last command done to the file being edited.</em>

8 0
3 years ago
Question 2 (2 points)
swat32

I beleive all of the above for question one

4 0
3 years ago
what is the molarity of a solution prepared by dissolving 15.0g of sodium hydroxide in enough water to make a total of 225 ml of
Reptile [31]

Answer:

1.6666 g/mol = 1 \frac{2}{3} g/mol

Explanation:

Molar mass of NaOH= 23+16+1 =40g/mol

Mols in 15g = 15/40 mol

If this was dissolved in 225ml of water molarity of the solution is

\frac{15}{40} ÷ 225 x 1000 = 1.6666 g/mol = 1 \frac{2}{3} g/mol

5 0
3 years ago
Other questions:
  • The ___ is the primary storage device of a personal computer. hard drive RAM ROM compact disc
    6·1 answer
  • 20 points/ When creating a storyboard, in which section do you mention how you move from one shot to the next?
    11·1 answer
  • A small company is requesting a quote to refresh its wireless network. The company currently runs 60 autonomous APs and has plan
    13·1 answer
  • A relational database is different from a simple database because it has more than one _____.
    13·1 answer
  • How do i move a file in python3
    10·1 answer
  • Which of the following are characteristics of algorithms? Choose all that apply. They take a step-by-step approach to performing
    12·1 answer
  • A bluetooth network consists of _____ primary device(s) and up to ____ secondary devices.
    8·1 answer
  • If a machine cycle is 2 nanoseconds , how many machine cycles occur each second?
    7·1 answer
  • What kind of energy transformation occurs when you call someone on a cell phone?
    11·1 answer
  • Briefly describe the working of computer processing system?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!