EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
Expert Solution & Answer
Book Icon
Chapter 3, Problem 5PE

Explanation of Solution

a.

Program code:

Percentages.java

//import the requird packages

import java.io.*;

//define a class Percentages

class Percentages

{

//define a method computePercent()

public static void computePercent(double num1,double num2)

{

//print the percentage values

System.out.println(num1+" is "+((num1/num2)*100)+" percent of "+num2+".");

}

//define the main method

public static void main (String[] args)

{

//declare two double values

double num1=2.0,num2=5...

Explanation of Solution

b.

Program code:

Percentage2.java

//import the requird packages

import java.util.Scanner;

import java.io.*;

//define a class Percentages

class Percentage2

{

//define a method computePercent()

public static void computePercent(double num1,double num2)

{

//print the percentage values

System.out.println(num1+" is "+((num1/num2)*100)+" percent of "+num2+".");

}

//define the main method

public static void main (String[] args)

{

        //declare two double variables

        double num1,num2;

        //create the object of Scanner

        Scanner sc=new Scanner(System.in);

        //prompt the user to enter the values

        System.out.println("Enter two numbers:");

        //scan for the values

num1=sc...

Blurred answer
Students have asked these similar questions
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
Create an application named Tables that computes the price of a table and chairs and whose Main() method calls the following methods: A method to accept the number of chairs to go with the table as input from the keyboard. This method returns the number of chairs to the Main() method. A method to accept as input and return the type of wood: p for pine, m for maple, and o or oak (use a loop to ensure only one of these letters is entered).  A method that accepts the number of chairs and wood type, and calculates the total cost of the desk based on the prices below. This method returns the total cost to the Main() method. Pine tables are $250. Maple tables are $300. All other wood types are $350. There will be an additional cost of $50 per chair. A minimum of 2 chair must be ordered (use a loop to ensure a value of 2 or more is entered.) A final method to display all the details and the final price. The image below shows a sample run of the program.
This assigment wants me to: Assume that a gallon of paint covers about 350 square feet of wall space. Create an application with a main() method that prompts the user for the length, width, and height of a rectangular room. Pass these three values to a method that does the following: Calculates the wall area for a room Passes the calculated wall area to another method that calculates and returns the number of gallons of paint needed Displays the number of gallons needed Computes the price based on a paint price of $32 per gallon, assuming that the painter can buy any fraction of a gallon of paint at the same price as a whole gallon Returns the price to the main() method The main() method displays the final price. For example: You will need 2.0 gallons The price to paint the room is $64.0 here is my code and this is all i have so far help please !       import java.util.Scanner; public class PaintCalculator {     public static void main (String args[]) {         int AreaPerGalllon =…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage