Java Programming, Loose-leaf Version
Java Programming, Loose-leaf Version
8th Edition
ISBN: 9781337685917
Author: Joyce Farrell
Publisher: Cengage Learning
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 3, Problem 8PE

Explanation of Solution

Program:

PaintCalculator.java

//import the required packages

import java.util.Scanner;

//define the class PaintCalculator

public class PaintCalculator

{

//declare the require constants

private static int AREA_PER_GALLON = 350;

private static double PRICE_PER_GALLON = 32;

//method that calculate the area, gallons of required paint and the total price

public static double calculate(double length, double height, double width)

{

//calculate the area

double area = length * height * 2 + width * height * 2;

//call the method calculateGallons()

double gallonsRequired = calculateGallons(area);

//print the gallonsRequired

System.out.println("Require Gallons of paint: " + gallonsRequired);

//calculate the price

double price = gallonsRequired * PRICE_PER_GALLON;

//return price

return price;

    }

//define the method calculateGallons()

public static double calculateGallons(double area)

{

//returns the number of gallons for the given area

return area/AREA_PER_GALLON;

}

//define the main method

public static void main(String[] args)

    {

//declare the required variables

int length, height, width;

//create the object for Scanner class

Scanner inputScanner = new Scanner(System.in);

//prompt the user to enter length of room

System.out.print("Enter Length of the room: ");

//read the length from the user

length = inputScanner.nextInt();

//prompt the user to enter width of room

System.out.print("Enter Width of the room: ");

//read the width from the user

width = inputScanner.nextInt();

//prompt the user to ente Height of room

System...

Blurred answer
Students have asked these similar questions
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 =…
Assume that a gallon of paint covers about 350 square feet of wall space. Create a class called PaintCalculator with a main() method that prompts the user for the length, width, and height of a rectangular room, all three of type double. Pass these three values to a method called computeArea() that does the following: Calculates the wall area for a room Passes the calculated wall area to another method called computeGallons() 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, the cost to paint a 15-by-20-foot room with 10-foot ceilings is $64. An example of the program is shown below; Enter the room's length >> 13.2 Enter the room's width >> 10.5 Enter the room's…
To encourage good grades, Hermosa High School has decided to award each student a bookstore credit that is 10 times the student’s grade point average. In other words, a student with a 3.2 grade point average receives a $32.0 credit. Create an application that prompts a student for a name and grade point average, and then passes the values to a method (computeDiscount) that displays a descriptive message. The message uses the student’s name, echoes the grade point average, and computes and displays the credit.
Knowledge Booster
Background pattern image
Computer Science
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
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    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
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,
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY