SoccerHalo
21.07.2019 •
Computers and Technology
What is the formula equivalent to the function =sum(b1: b5)?
Solved
Show answers
More tips
- S Sport How does Bodyflex work: what is it and how does it work?...
- O Other What is the oldest joke ever told?...
- F Food and Cooking How to Make Lazy Cabbage Rolls? Simple Steps to a Delicious Dish...
- F Food and Cooking Unusually Delicious Shashlik - Follow the Etiquette of Proper Preparation!...
- L Leisure and Entertainment Couchsurfing: A New Way to Travel...
- G Goods and services Which TV is better - LCD or Plasma?...
- S Sport How to Learn to Pull Up on Monkey Bars?...
- L Leisure and Entertainment Scrapbooking: What is it and Why is it Becoming More Popular?...
- C Computers and Internet Where did torrents.ru move to?...
- B Business and Finance Understanding Cash Flow: What It Is and How It Works...
Answers on questions: Computers and Technology
- H History Refer to the excerpt below. We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable...
- M Mathematics Using the information given, select the statement that can deduce the line segments to be parallel. If there are none, then select none. When m7 = m8 none...
- M Mathematics Hello:) how to do this? using partial fractions...
- C Chemistry Compare and contrast the following scenarios: A gas dissolving in a liquid at room temperature with the temperature gradually rising to 110 °F vs a solid dissolving...
- M Mathematics Calculate the number in the middle of 15 and 24...
Ответ:
Ответ:
import java.util.Scanner;
public class PaintClculator {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter Values for length, width, and height of the room");
double length = in.nextDouble();
double width = in.nextDouble();
double height = in.nextDouble();
double wallArea = calculateWallArea(length,width,height);
double noGallons = calculatePaint(wallArea);
double price = price(noGallons);
System.out.println("Price is: "+ price);
}
// Creating Method to Calculate Wall Area
public static double calculateWallArea( double length, double width, double height){
// formular for the surface area of a room Area=2*length*heigth+2*width*height+lenth*width
double Area = 2*length*height+2*width*height+length*width;
System.out.println("Wall Area: "+Area);
return Area;
}
//Creating method to calculate amount of paint
public static double calculatePaint(double Area){
double noGallons = Area/350;
System.out.println("Number of gallons: "+noGallons);
return noGallons;
}
// Creating Method Calculate Price
public static double price(double noGallons){
return noGallons*32;
}
}
Explanation
Created Three Methods in all; calculateWallArea(), calculatePaint(), and price()Method calculateWallArea() calculates area based on this formula Area=2*length*heigth+2*width*height+lenth*widthThe value of Area is passed to method calculatePaint() Which calculates the number of gallons required to cover the area given that one gallon covers 350 wall spaceMethod price() calculates and dis[plays the price by calling method calculatePaint() that returns number of gallons. since one gallon is 32$