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.0 percent of 5.0.” Then call the method a second time, passing the values in reverse order. For testing use the values 2.0 and 5.0. An example of the program is shown below: 2.0 is 40.0 percent of 5.0 5.0 is 250.0 percent of 2.0

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

Modify the Percentages application 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.0 percent of 5.0.”

Then call the method a second time, passing the values in reverse order.

For testing use the values 2.0 and 5.0.

An example of the program is shown below:

2.0 is 40.0 percent of 5.0 5.0 is 250.0 percent of 2.0

* CENGAGE MINDTAP
Q Search this course
Programming Exercise 3-5A
Instructions
Percentages.java
>- Terminal
1 public class Percentages {
public static void main (String args[]) {
// write your code here
sandbox $ rm -f *.class
sandbox $
sandbox $
sandbox $ javac Percentages.java
sandbox $ java Percentages
sandbox $0
Modify the Percentages application whose main()
method holds two double variables. Assign values
3
4
to the variables.
public static void computePercent(double x, double y) {
</>
// write your code here
6.
Pass both variables to a method named
7
8 }
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.0 percent of 5.0."
Then call the method a second time, passing the
values in reverse order.
For testing use the values 2.0 and 5.0.
An example of the program is shown below:
2.0 is 40.0 percent of 5.e
5.0 is 250.0 percent of 2.0
Grading
10:45 PM
Transcribed Image Text:* CENGAGE MINDTAP Q Search this course Programming Exercise 3-5A Instructions Percentages.java >- Terminal 1 public class Percentages { public static void main (String args[]) { // write your code here sandbox $ rm -f *.class sandbox $ sandbox $ sandbox $ javac Percentages.java sandbox $ java Percentages sandbox $0 Modify the Percentages application whose main() method holds two double variables. Assign values 3 4 to the variables. public static void computePercent(double x, double y) { </> // write your code here 6. Pass both variables to a method named 7 8 } 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.0 percent of 5.0." Then call the method a second time, passing the values in reverse order. For testing use the values 2.0 and 5.0. An example of the program is shown below: 2.0 is 40.0 percent of 5.e 5.0 is 250.0 percent of 2.0 Grading 10:45 PM
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 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