Ask Question
30 April, 01:45

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.

+3
Answers (1)
  1. 30 April, 04:55
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers