Hello! I am just starting to learn about methods and am somewhat confused. I am doing an exercise program with a scenario. A painting company has determined that for every 115 square feet of wall space, one gallon of
paint and eight hours of labor will be required. The company charges $18.00 per hour for labor. Write a program
that allows the user to enter the number of rooms to be painted and the price of the paint per gallon. It should
also ask for the square feet of wall space in each room. The program should have methods that return the following
data:
1. The number of gallons of paint required
2. The hours of labor required
3. The cost of the paint
4. The labor charges
5. The total cost of the paint job
I am getting a lot of errors in this. This is my first try at doing methods and am having a extremely hard time. Here's what I have so far:
CODE
import java.util.Scanner;
public class paint
{
public static void main (String[ ] args)
{
//Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
rooms ();
price ();
square();
int room, price, sqtft, gallon, labor, cost, laborc, total;
gallon = sqtft / 115;
labor = (sqtft * 8) / 115;
cost = (sqtft * price) / 115;
laborc = labor * 18;
total = laborc + cost;
while (room < 1 || price < 1 || sqtft < 1)
{
System.out.println("Please enter correct amount.");
System.out.println("How many rooms are in the house?");
room = keyboard.nextInt();
System.out.println("What is the price of the paint per gallon?");
price = keyboard.nextInt();
System.out.println("What is the square feet of the wall space per room?");
sqtft = keyboard.nextInt();
}
System.out.println("The number of gallons of paint required are: " + gallon);
System.out.println("The hours of labor required are: " + labor);
System.out.println("The cost of the paint is: $" + cost);
System.out.println("The labor charges are: $" + laborc);
System.out.println("The total cost of the paint job is: $" + total);
}
public static void rooms()
{
System.out.println("How many rooms are in the house?");
room = keyboard.nextInt();
}
public static void price()
{
System.out.println("What is the price of the paint per gallon?");
price = keyboard.nextInt();
}
public static void square()
{
System.out.println("What is the square feet of the wall space per room?");
sqtft = keyboard.nextInt();
}
}//end class
Every single one of the examples in that I see in the book are done with strings and not integers. I don't know if that'll make a difference but I don't know exactly how to correct the problem. Any help will be appreciatted!