Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone tell me what is wrong with the red underlined code? Using JAVA, I'm supposed to debug this using Netbeans. This has copied copied

Can anyone tell me what is wrong with the red underlined code? Using JAVA, I'm supposed to debug this using Netbeans. This has copied copied and pasted directly from the assignment, but we haven't learned anything about lines 1, 2, 4, or 6 yet. So, I haven't the first clue if they are right or not, that's all Greek to me at this point. Also, line 32 we have learned a little bit about this, I think the operation needs to be adjusted to output a proper estimate. But it also has some weird coversion error, we haven't learned about that though either?

Thanks.

import java.util.Scanner; //(1)*****class, interface, or enum expected*****

import java.lang.Math; // Note: Needed for math functions \\ (2)*****class, interface, or enum expected*****

public class PaintEstimator { public static void main(String[] args) {

Scanner scnr = new Scanner(System.in); \\(4)*****cannot find symbol, symbol class: class scanner, location: PaintEstimator*****

double wallHeight = 0.0;

double wallWidth = 0.0;

double wallArea = 0.0;

double gallonsPaintNeeded = 0.0;

int cansNeeded = 0;

final double squareFeetPerGallons = 350.0;

final double gallonsPerCan = 1.0;

System.out.println("Enter wall height (feet): ");

wallHeight = scnr.nextDouble(); // Prompt user to input wall's width

System.out.println("Enter wall width (feet): ");

wallHeight = scnr.nextDouble(); // Calculate and output wall area

wallArea = wallHeight * wallWidth;

System.out.println("Wall area: square feet"); // Calculate and output the amount of paint in gallons needed to paint the wall

gallonsPaintNeeded = wallArea/squareFeetPerGallons;

System.out.println("Paint needed: " + gallonsPaintNeeded + " gallons"); // Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer

cansNeeded = (gallonsPaintNeeded / gallonsPerCan); //Hint: this line is missing two operations (32) *****incompatible types: possibly lossy conversion from double to int******

System.out.println("Cans needed: " + cansNeeded + " can(s)");

return;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Understand how market research prepares you for success.

Answered: 1 week ago

Question

What is the purpose of the staffing practice called Two-in-aBox?

Answered: 1 week ago