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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education