Ask Question
1 September, 01:08

Create an application named Percentages whose main () method holds two double variables. Assign values to the variables. Pass both variables to a method named computePercent () that displays the two values and the value of the first number as a percentage of the second one. For example, if the numbers are 2.0 and 5.0, the method should display a statement similar to "2.0 is 40 percent of 5.0." Then call the method a second time, passing the values in reverse order.

+2
Answers (1)
  1. 1 September, 03:13
    0
    The codes below implement the problem statements

    Explanation:

    public class Percentages {

    public static void computePercent (int a, int b)

    {

    System. out. println (a+" is " + (a*100/b) + "% of "+b);

    }

    public static void main (String []args)

    {

    int a=2;

    int b=5;

    computePercent (a, b);

    computePercent (b, a);

    }

    }

    Part (b)

    import java. util.*;

    public class Percentages {

    public static void computePercent (int a, int b)

    {

    System. out. println (a+" is " + (a*100/b) + "% of "+b);

    }

    public static void main (String []args)

    {

    Scanner s = new Scanner (System. in);

    int a=s. nextInt ();

    int b=s. nextInt ();

    computePercent (a, b);

    computePercent (b, a);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Create an application named Percentages whose main () method holds two double variables. Assign values to the variables. Pass both ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers