Ask Question
24 December, 06:48

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.

+4
Answers (1)
  1. 24 December, 07:06
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers