Create a class named Percentages whose main() method holds two double variables, and prompt the user for values. 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. An example of the program is shown below: Enter a double >> 3.7 Enter another double >> 12.3 3.7 is 30.081300813008127 percent of 12.3 12.3 is 332.43243243243245 percent of 3.7 Task 01: Create the Percentages class. Task 02: The computePercent() method displays the percent of the first argument of the second argument. Task 03: The Percentages program accepts 2 double values from the console and displays the percent of first value of the second value and vice versa.
Create a class named Percentages whose main() method holds two double variables, and prompt the user for values. 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.
An example of the
Enter a double >> 3.7 Enter another double >> 12.3 3.7 is 30.081300813008127 percent of 12.3 12.3 is 332.43243243243245 percent of 3.7
Task 01: Create the Percentages class.
Task 02: The computePercent() method displays the percent of the first argument of the second argument.
Task 03: The Percentages program accepts 2 double values from the console and displays the percent of first value of the second value and vice versa.
![Q4 %
€03
C
> OUTLINE
> TIMELINE
Ö
> JAVA PROJECTS
* Codespaces: literate sniffle
chegg.codebugth C chegg.co
https://literate-sniffle-x5wx9wg5x7w4fr5r.github.dev/?folder=/workspaces/9780357673423_java-programming-10e-5... B Q A" ☆ {}
EXPLORER
STUDENT [CODESPACES: LITERATE SNIFFLE]
J Percentages.class
J
Percentages.java
Min X
template A0
Con X
J Percentages.java X
J Percentages.java > % Percentages
1 // Write your code here
2
import java.util.Scanner;
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 }
Suc X
}
public class Percentages (
public static void main (String args[]) {
Scanner scan = new Scanner(System.in);
double x, y;
}
insu X
java X
System.out.print("Enter value for x: ");
x = scan.nextDouble();
System.out.print("Enter value for y: ");
y = scan.nextDouble();
computePercent(x,y);
computePercent (y,x);
1 Java Lightweight Mode
form X
public static void computePercent (double x, double y) {
System.out.printf("%.1f is %.ef percent of %.1f.\n",x, (x/y)*100,y);
chegg.co C chegg.co
student (Codespaces: literate sniffle]
Th
Mww.s
Mes
www
Enter a double >> 3.7
Enter another double >> 12.3
Welcome
= Companion X
method a second time, passing the values in reverse order.
An example of the program is shown below:
3.7 is 30.081300813008127 percent of 12.3
12.3 is 332.43243243243245 percent of 3.7
X
X
PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL PORTS 1 COMMENTS
@jbowen3225 →.../9780357673423_java-programming-10e-5d83f9ac-c9c6-4288-9e22-37326c529145/chapter3/ex04/student (template) $
New tab
Task 01: Create the Percentages class.
(D
+
·[+]
Task 02: The computePercent() method displays the percent of the first
argument of the second argument.
Task 03: The Percentages program accepts 2 double values from the console
and displays the percent of first value of the second value and vice versa.
>
bash + I
用
4
❤
<>
Ő
Layout: US
08
C](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F63639615-d990-48b7-9249-2331d859943f%2Fb286af9b-4602-472d-b0af-898cf5e7967b%2Fyov7owd_processed.png&w=3840&q=75)

Step by step
Solved in 4 steps with 2 images









