Question

Java Programming A program is required to calculate the amount of paint needed for painting a...

Java Programming

A program is required to calculate the amount of paint needed for painting a
fence. The program assumes that 1 litre of paint covers 5 m^2 and that the
user is able to input the height and the length of the fence.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class PaintCalculator {
  
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the length of the fence: ");
double length = Double.parseDouble(sc.nextLine().trim());
System.out.print("Enter the height of the fence: ");
double height = Double.parseDouble(sc.nextLine().trim());
  
// calculate the area of the fence
double fenceArea = (length * height);
  
// Paint required for painting 5 m^2 of fence = 1L
double painRequired = (fenceArea / 5);
  
System.out.println("Amount of paint required to paint "
+ String.format("%.2f", fenceArea) + " m^2 of fence = " + String.format("%.2f", painRequired) + " L.\n");
}
}

****************************************************************** SCREENSHOT *********************************************************

Add a comment
Know the answer?
Add Answer to:
Java Programming A program is required to calculate the amount of paint needed for painting a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need to write a paint job estimator program in python. I have most of it...

    I need to write a paint job estimator program in python. I have most of it down but i keep getting errors and I dont know how to fix it or what im doing worng specs: A painting company has determined that for every 350 square feet of wall space, one gallon of paint and six hours of labor are required. The company charges $62.25 per hour for labor. Write a program call paintjobestimator.py that asks the user to enter...

  • Programming Project #5 Project Outcomes: Develop a Java program that Uses selection constructs (if, and if...

    Programming Project #5 Project Outcomes: Develop a Java program that Uses selection constructs (if, and if else). Uses the Java iteration constructs (while, do, for). Uses static variables. Ensure integer variables input are within a range that will not cause integer overflow. Uses proper design techniques including reading UML Class Diagrams Background Information: The Unified Modeling Language (UML) provides a useful notation for designing and developing object-oriented software systems. One of the basic components of the UML is a class...

  • In Java Programming: Create a flow chart for a program that prompts for an integer N...

    In Java Programming: Create a flow chart for a program that prompts for an integer N (number of students) and M (number of test scores for each students), and allows the user to N*M real numbers. The program then calculates the average for each student and class average. (1) Prompt the user to input N students and M test scores, then display the inputs. Enter number of students: You entered: 2 Enter number of test scores: You entered: 3 Enter...

  • Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate...

    Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate rectangle area. Some requirements: 1. User Scanner to collect user input for length & width 2. The formula is area = length * width 3. You must implement methods getLength, getWidth, getArea and displayData ▪ getLength – This method should ask the user to enter the rectangle’s length and then return that value as a double ▪ getWidth – This method should ask the...

  • Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the...

    Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the Area of a Circle 2.       Calculate the Area of a Triangle 3.     Calculate the Area of a Rectangle 4.       Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the formula:      area = ∏r2    Use 3.14159 for ∏. If the user enters 2 the program should ask for...

  • Specifications: • Prompt the user to input a wall's height and width. Calculate and output the...

    Specifications: • Prompt the user to input a wall's height and width. Calculate and output the wall's area. • Extend to also calculate and output the amount of paint in gallons needed to paint the wall. Assume a gallon of paint covers 350 square feet Store this value using a const double variable. • Extend to also calculate and output the number of 1 gallon cans needed to paint the wall. Hint: Use a math function to round up to...

  • allpaint in java

    AllPaint is a shop that specialises in household paint products. They have approached you, an application developer for your services. They want you to develop an application that they will use in their shop to estimate the amount of paint that customers would need to purchase when they supply dimensions of their houses. Furthermore, they want you to integrate this system with their point of sale system, which would enable them to process paint sales. To process a sale, the...

  • Java Programming----- Creating a Mortgage Calculator Program

    Write the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgageand the user's selection from a menu of available mortgage loans:•7 years at 5.35%•15 years at 5.5%•30 years at 5.75%Use an array for the mortgage data for the different loans. Read the interest rates to fill the array from a sequential file. Display the mortgage payment amountfollowed by the loan balance and...

  • Use DevC++ to implement a program uses objected oriented programming to calculate the area of a...

    Use DevC++ to implement a program uses objected oriented programming to calculate the area of a rectangle. The program should create a Rectangle class that has the following attributes and member functions: Attributes: width and length Member functions: setWidth(), setLength(), getWidth() , getLength(), getArea() Where width and length are the respect width and length of a Rectangle class. The setWidth() and setLength() member function should set the length and width, the getWidth(), getLenght(), and getArea() member function should get the...

  • in python please (1) Prompt the user to input a wall's height and width. Calculate and...

    in python please (1) Prompt the user to input a wall's height and width. Calculate and output the wall's area (integer). (Submit for 2 points). Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet (2) Extend to also calculate and output the amount of paint in gallons needed to paint the wall (floating point). Assume a gallon of paint covers 350 square feet. Store this value in a variable. Output the amount of paint...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT