Based on the java code below, how to develop a Junit code to Test for public class Driver1 using JUNIT code package stubdriver; /** * Converts from one unit to another (e.g., inches to feet) * * @author Prof. David Bernstein, James Madison University * @version 1.0 (Implemented getMultiplier) */ public class UnitConverter1 { /** * Default Constructor */ public UnitConverter1() { } /** * Perform a conversion * * @param value The number to convert * @param from The units for value (e.g., "inches") * @param to The units to convert to (e.g., "feet") * @return The converted value */ publicdouble convert(double value, String from, String to) {     double result;     result = value * getMultiplier(from, to);     return result; } /** * Get the multiplier needed for a conversion * * @param from The units to convert from (e.g., "inches") * @param to The units to convert to (e.g., "feet") * @return What "from" needs to be multiplied by to get "to" */ publicdouble getMultiplier(String from, String to) {     double multiplier;     multiplier = 1.0;     if (from.equals("inches")) {      if (to.equals("feet")) multiplier = 1.0/12.0;      else if (to.equals("yards")) multiplier = 1.0/12.0/3.0;      else if (to.equals("miles")) multiplier = 1.0/12.0/3.0/1760.0;     } else if (from.equals("feet")) {      if (to.equals("inches")) multiplier = 12.0;      else if (to.equals("yards")) multiplier = 1.0/3.0;      else if (to.equals("miles")) multiplier = 1.0/3.0/1760.0;     } else if (from.equals("yards")) {      if (to.equals("inches")) multiplier = 3.0*12.0;      else if (to.equals("feet")) multiplier = 3.0;      else if (to.equals("miles")) multiplier = 1.0/1760.0;     } else if (from.equals("miles")) {      if (to.equals("inches")) multiplier = 12.0*3.0*1760.0;      else if (to.equals("yards")) multiplier = 1760.0;      else if (to.equals("feet")) multiplier = 3.0*1760.0;     }     return multiplier; } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Based on the java code below, how to develop a Junit code to Test for public class Driver1 using JUNIT code

package stubdriver;

/**
* Converts from one unit to another (e.g., inches to feet)
*
* @author Prof. David Bernstein, James Madison University
* @version 1.0 (Implemented getMultiplier)
*/
public class UnitConverter1
{


/**
* Default Constructor
*/
public UnitConverter1()
{
}


/**
* Perform a conversion
*
* @param value The number to convert
* @param from The units for value (e.g., "inches")
* @param to The units to convert to (e.g., "feet")
* @return The converted value
*/
publicdouble convert(double value, String from, String to)
{
    double result;

    result = value * getMultiplier(from, to);
    return result;
}



/**
* Get the multiplier needed for a conversion
*
* @param from The units to convert from (e.g., "inches")
* @param to The units to convert to (e.g., "feet")
* @return What "from" needs to be multiplied by to get "to"
*/
publicdouble getMultiplier(String from, String to)
{
    double multiplier;

    multiplier = 1.0;
    if (from.equals("inches")) {

     if (to.equals("feet")) multiplier = 1.0/12.0;
     else if (to.equals("yards")) multiplier = 1.0/12.0/3.0;
     else if (to.equals("miles")) multiplier = 1.0/12.0/3.0/1760.0;

    } else if (from.equals("feet")) {

     if (to.equals("inches")) multiplier = 12.0;
     else if (to.equals("yards")) multiplier = 1.0/3.0;
     else if (to.equals("miles")) multiplier = 1.0/3.0/1760.0;

    } else if (from.equals("yards")) {

     if (to.equals("inches")) multiplier = 3.0*12.0;
     else if (to.equals("feet")) multiplier = 3.0;
     else if (to.equals("miles")) multiplier = 1.0/1760.0;

    } else if (from.equals("miles")) {

     if (to.equals("inches")) multiplier = 12.0*3.0*1760.0;
     else if (to.equals("yards")) multiplier = 1760.0;
     else if (to.equals("feet")) multiplier = 3.0*1760.0;
    }

    return multiplier;
}

}

package stubdriver;

/**
* A driver for testing the UnitConverter class
*
* @author Prof. David Bernstein, James Madison University
* @version 2.0
*/
public class Driver1
{
/**
* The entry point of the application
*
* @param args The command-line arguments
*/
public static void main(String[] args)
{
double converted, original;
int i, j;
String from, to;
String[] units = {"inches","feet","yards","miles"};
UnitConverter1 calculator;


calculator = new UnitConverter1();

original = 10.0;

for (i=0; i < units.length; i++) {
for (j=0; j < units.length; j++) {

from = units[i]; // This could be outside the inner loop
to = units[j];
converted = calculator.convert(original, from, to);
System.out.println(original+" "+from+" = "+converted+" "+to);
}
}
}

}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY