EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
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
Assume that a string of name & surname is saved in S. The alphabetical characters in S can be in lowercase and/or uppercase letters. Name and surname are assumed to be separated by a space character and the string ends with a full stop "." character. Write an assembly language program that will copy the name to NAME in lowercase and the surname to SNAME in uppercase letters. Assume that name and/or surname cannot exceed 20 characters. The program should be general and work with every possible string with name & surname. However, you can consider the data segment definition given below in your program. .DATA S DB 'Mahmoud Obaid." NAME DB 20 DUP(?) SNAME DB 20 DUP(?) Hint: Uppercase characters are ordered between 'A' (41H) and 'Z' (5AH) and lowercase characters are ordered between 'a' (61H) and 'z' (7AH) in the in the ASCII Code table. For lowercase letters, bit 5 (d5) of the ASCII code is 1 where for uppercase letters it is 0. For example, Letter 'h' Binary ASCII 01101000 68H 'H'…
What did you find most interesting or surprising about the scientist Lavoiser?
1. Complete the routing table for R2 as per the table shown below when implementing RIP routing Protocol? (14 marks) 195.2.4.0 130.10.0.0 195.2.4.1 m1 130.10.0.2 mo R2 R3 130.10.0.1 195.2.5.1 195.2.5.0 195.2.5.2 195.2.6.1 195.2.6.0 m2 130.11.0.0 130.11.0.2 205.5.5.0 205.5.5.1 R4 130.11.0.1 205.5.6.1 205.5.6.0
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
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
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