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.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 2CP: In Chapter 11, you created the most recent version of the MarshallsRevenue program, which prompts...
icon
Related questions
Question
100%

 

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.

 

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
Transcribed Image Text: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
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,