Program Specifications Write a program to calculate the cost to paint a wall. Amount of required paint is based on the wall area. Total cost includes paint and sales tax. Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. Step 1 (2 pts). Read from input wall height, wall width, and cost of one paint can (doubles). Calculate and output the wall's area to one decimal place using System.out.printf("Wall area: %.1f sq ft\n", area);. Submit for grading to confirm 1 test passes. Ex: If the input is: 12.0 15.0 29.95 the output is: Wall area: 180.0 sq ft Step 2 (2 pts). Calculate and output the amount of paint needed to three decimal places. One gallon of paint covers 350 square feet. Submit for grading to confirm 2 tests pass. Ex: If the input is: 12.0 15.0 29.95 the output is: Wall area: 180.0 sq ft Paint needed: 0.514 gallons Step 3 (2 pts). Calculate and output the number of 1 gallon cans needed to paint the wall. Extra paint may be left over. Hint: Use Math.ceil() to round up to the nearest gallon and convert to an integer. Submit for grading to confirm 4 tests pass. Ex: If the input is: 12.0 15.0 29.95 the output is: Wall area: 180.0 sq ft Paint needed: 0.5142 gallons Cans needed: 1 can (s) Step 4 (4 pts). Calculate and output the paint cost, sales tax of 7%, and total cost. Dollar values are output with two decimal places. Submit for grading to confirm all tests pass. Ex: If the input is: 8.0 8.0 49.20 the output is: Wall area: 64.0 sq ft Paint needed: 0.183 gallons Cans needed: 1 can (s) Paint cost: $49.20 Sales tax: $3.44 Total cost: $52.64 1 import java.util.Scanner; 2 3 public class LabProgram { 4 5 6 7 8 9 10 11 12 13} 14 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); } int area; double wallHeight; double wallWidth; System.out.printf("Wall area: %.1f sq ft\n", area);
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
Java - Painting a Wall
![Program Specifications Write a program to calculate the cost to paint a wall. Amount of required paint is based on the wall area. Total cost
includes paint and sales tax.
Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only
a portion of tests pass after each step but confirm progress.
Step 1 (2 pts). Read from input wall height, wall width, and cost of one paint can (doubles). Calculate and output the wall's area to one
decimal place using System.out.printf("Wall area: %.1f sq ft\n", area);. Submit for grading to confirm 1 test passes.
Ex: If the input is:
12.0 15.0 29.95
the output is:
Wall area: 180.0 sq ft
Step 2 (2 pts). Calculate and output the amount of paint needed to three decimal places. One gallon of paint covers 350 square feet.
Submit for grading to confirm 2 tests pass.
Ex: If the input is:
12.0 15.0 29.95
the output is:
Wall area: 180.0 sq ft
Paint needed: 0.514 gallons
Step 3 (2 pts). Calculate and output the number of 1 gallon cans needed to paint the wall. Extra paint may be left over. Hint: Use Math.ceil()
to round up to the nearest gallon and convert to an integer. Submit for grading to confirm 4 tests pass.
Ex: If the input is:
12.0 15.0 29.95
the output is:
Wall area: 180.0 sq ft
Paint needed: 0.5142 gallons
Cans needed: 1 can (s)
Step 4 (4 pts). Calculate and output the paint cost, sales tax of 7%, and total cost. Dollar values are output with two decimal places. Submit
for grading to confirm all tests pass.
Ex: If the input is:
8.0 8.0 49.20
the output is:
Wall area: 64.0 sq ft
Paint needed: 0.183 gallons
Cans needed: 1 can (s)
Paint cost: $49.20
Sales tax: $3.44
Total cost: $52.64
1 import java.util.Scanner;
2
3 public class LabProgram {
4
5
8
10
11
12
13
14
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
}
int area;
double wallHeight;
double wallWidth;
System.out.printf("Wall area: %.1f sq ft\n", area);](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F73901183-513c-4b44-b5b0-c95e8b35aeb4%2F3dfbcb30-c0bb-4593-84a8-8ccbe90c6525%2Fp938v0p_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images









