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
How many rows appear in a truth table for the compound proposition: \[(p \leftrightarrow q) \oplus (\neg p \leftrightarrow \neg
AURORKA [14]
Let me re-write the proposition:

p↔q⊕(¬p↔¬r)∧¬q.

Generally, the number of rows in a truth table depends on the number of Variables. Here we have 3 Variables: p,q and r. Each of them can have either the value of 1 or 0, which gives us 2*2*2 possibilities, or 2³, that is 8 possibilities and 8 rows:

p=0, q=0, r=0
p=0, q=0, r=1
p=0, q=1, r=0
p=0, q=1, r=1
p=1, q=0, r=0
p=1, q=0, r=1
p=1, q=1, r=0
p=1, q=1, r=1







4 0
2 years ago
Write two statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a slash, and
Montano1993 [528]

Answer:

1/2000

Explanation:

import java.util.Scanner;

public class InputExample {

public static void main(String [] args) {

Scanner scnr = new Scanner(System.in);

System.out.print("Enter birth month and date:");//comment this line if not needed

int birthMonth=scnr.nextInt();

int birthYear=scnr.nextInt();

String output= birthMonth+"/"+birthYear+"\n";

System.out.println(output);

}

}

if using this code the out put should be 1/2000

5 0
2 years ago
Research 3 distributions that utilize the big data file systems approaches, and summarize the characteristics and provided funct
OlgaM077 [116]

Answer:

Explanation:

1: The three most popular data systems that make use of Big Data file systems approach are:

The HDFS (Hadoop Distributed File System), Apache Spark, and Quantcast File System(QFS).

HDFS is the most popular among these and it makes use of the MapReduce algorithm to perform the data management tasks. It can highly tolerate faults and can run on low-cost hardware. It was written in Java and it is an open-source software.

Apache Spark makes use of Resilient Distributed Data (RDD) protocol. It is much faster and lighter than the HDFS and it can be programmed using a variety of languages such as Java, Scala, Python, etc. Its main advantage over HDFS is that it is highly scalable.

While QFS was developed as an alternative to the HDFS and it is also highly fault-tolerant and with space efficient. It makes use of the Reed-Solomon Error Correction technique to perform the task of data management.

2: The NewSQL databases were developed as a solution to the scalability challenges of the monolithic SQL databases. They were designed to allow multiple nodes in the context of an SQL database without affecting the replication architecture. It worked really well during the starting years of the cloud technology. Some of the databases that make use of New SQL technology are Vitess, Citus, etc.

Vitess was developed as an automatic sharding solution to the MySQL. Every MySQL instance acts as a shard of the overall database and each of these instances uses standard MySQL master-slave replication to ensure higher availability.

While, Citus is a PostgreSQL equivalent of the Vitess. It ensures transparent sharding due to which it accounts for horizontal write scalability to PostgreSQL deployments.

NoSQL database technology was developed to provide a mechanism for the storage and retrieval of data that is modeled in a way other than the tabular relations used in the traditional databases (RDBMS). The most popular database that makes use of the NoSQL technology is MongoDB. It functions as a cross-platform document-oriented database. It is known for its ability to provide high availability of replica sets. A replica set is nothing but a bundle of two or more copies of the data

3 0
3 years ago
Does the wireless signal between the cell phones require matter to travel from one phone to another?
mrs_skeptik [129]

Mobile phones transmit and receive signals using electromagnetic waves, that is, wireless signal are electromagnetic waves which can travel through a vacuum, they do not need a medium or matter.

<h3>What are electromagnetic waves?</h3>

They are generated by electrical and magnetic particles moving at the same time (oscillating).

<h3>Characteristics of electromagnetic waves</h3>

  • Network waves are electromagnetic waves.

  • A mobile phone has coverage when it receives electromagnetic waves from at least one base station.

  • They do not necessarily require a material medium for their propagation.

Therefore, we can conclude that electromagnetic waves are those that do not need a material medium to propagate and include, among others, radio, television and telephone waves.

Learn more about electromagnetic waves here: brainly.com/question/13803241

3 0
2 years ago
Of the choice below,access to with tab will start a power point presentation
kow [346]

the menu and the toolbars
4 0
3 years ago
Other questions:
  • Assume you have just started a new job, have a car loan, and have a student loan. You have just received a cash gift of $1,000 f
    14·1 answer
  • Prompt the user ‘Enter a row vector of any numbers’ in the command window, and enter an arbitrary row vector and store it to x.
    6·1 answer
  • Write two separate formulas using different commands that concatenate " john and "smith" together to form " John Smith"
    9·1 answer
  • The following relation schema can be used to register information on the repayments on micro loans.
    13·1 answer
  • PLEASE HURRY!!!
    11·1 answer
  • An alarm clock draws 0.5 A of current when connected to a 120 volt circuit. Calculate its resistance.
    10·1 answer
  • I think my knee....
    14·1 answer
  • What are the features of a computer speaker​
    10·1 answer
  • When a Select Case statement executes, the value of the test expression is compared with the values that follow each of the ____
    7·1 answer
  • A technician wants to replace a failing power supply on a high-end gaming computer. which form factor should the technician be l
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!