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...
Trending nowThis is a popular solution!
Chapter 3 Solutions
EBK JAVA PROGRAMMING
- Code the following: Language : Java Create a method called triangle that will take in three angles and tell you if you have a triangle Create an overloaded version of the triangle method that only takes in one angle and tells you if it could be a triangle create an overloaded version of the triangle method that only takes in two angles. You must check if it's possible for it to be an isosceles triangle. Don't forget to check both angles : example: angle1*2 + angle2 == 180 or angle1 +angle2*2 == 180arrow_forwardmaximum hours (inclusive). Make sure to cast the maximum range to an int before using it as parameter invoke the method to start the engine invoke the fly method and use as the input parameter the random number generated on the previous step invoke the method to land the plane and stop the engine invoke the addGas method. Invoke the calcGasNeededToFillTank () method to figure out the fuel needed to fill the tank and pass this value as input parameter to the addGas method.arrow_forwardC# LANGUAGE Create a method named getCircleDiameter that takes a radius of double type as the parameter. The method should return the diameter of a circle. To compute the diameter of a circle, multiply the radius by 2.arrow_forward
- 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. An example of the program is shown below: Enter your name >> John Enter your gpa >>3.4 John, your GPA is 3.4, so your credit is $34.0arrow_forwardInstructions: IMPORTANT: This is a continuation of the previous part of the project and assumes that you are starting with code that fulfills all requirements from that part of the project. Modify the your code from the previous part of the project to make it modular. In addition to the main method, your code must include the following static methods: Method 1 - displayTitle A method that creates a String object in memory to hold the text “Computer Hardware Graphics Quality Recommendation Tool” and displays it Method 2 – getResolutionString A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution. The method should return the appropriate String representation of the monitor resolution. For example, if the method is passed an integer value of 1, it should return a String with a value of “1280 x 720”. (See Step 4 of Project 1) Method 3 – getMultiplierValue A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution and…arrow_forwardplease i need the answers ASAParrow_forward
- Java Programming The program must use a method The program has 4 racers and the race is 50 units long. This program ends the race if any racer passes the ending point and print who won the race. Each racer moves randomly either: a. range from 3 to 8 units b. 5 sin(5) c. 45/2turn, but at least moves 1 unitarrow_forward// Question 4: // 20 Points // Declare an integer variable named "variableQ4" with an initial value of 10. // Write a method named "SetToOne" that takes one out parameter. // The method should set the out parameter to 1. // Call the method SetToOne passing variableQ4 in the btnQ4 click method. // Display the variable variableQ4 in the lblQ4. 1 reference private void btnQ4_Click(object sender, EventArgs e) { }arrow_forward// Question 4: // Declare an integer variable named "variables with an initial value of 10. // Write a method named "SetToOne" that takes one out parameter. // The method should set the out parameter to 1. // Call the method SetToOne passing variables in the btngs click method. // Display the variable variables in the lblQ4. private void btn04_Click(object sender, EventArgs e) {arrow_forward
- Create a method that takes a value and indicate whether it is positive or negative by a return aBoolean value.Declared as: boolean isPositive (float a)arrow_forwardDesign the worst calculator ever: an application that accepts two numbers from the user and, when a button is pushed, performs a single operation and displays the results. You may choose: Multiplication, Division, Subtraction, square root, or raising the first number to the exponent of the second number. Don't use addition as we already did that in class. The result must be displayed to the user only when an appropriately labeled button is pushed.arrow_forwardin c# please Write method QualityPoints that inputs a student’s average and returns 4 if the student’s average is 90–100, 3 if the average is 80–89, 2 if the average is 70–79, 1 if the average is 60–69 and 0 if the average is lower than 60. Incorporate the method into an app that reads a value from the user and displays the result.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage