I need to create a simple system that can tell the painters how much paint is ne
ID: 3625316 • Letter: I
Question
I need to create a simple system that can tell the painters how much paint is needed and how much it will cost.For this system the user will be asked to input the size (height, width, and length) of the rooms that they will need to paint. They will also be asked if the walls are textured, or not textured; this is important because textured walls take more paint than untextured walls. We will assume that textured walls will need 1 gallon of paint for every 200 Square feet, and that smooth walls will need 1 gallon for every 350 square feet.There is no set number of rooms, but rather the user can keep inputting these rooms until there are no more rooms. (We will assume for simplicity that all of the rooms are square or rectangle…and no slanted ceilings)
Sample Dialog of Room Entry:
Please enter the height of room number 1 (in feet):
20
Please enter the width of room number 1 (in feet):
10
Please enter the length of room number 1 (in feet):
20
Are the walls textured? (Y or N)
Y
Do you have to enter another room? (Y or N)
Y
Please enter the height of room number 2 (in feet):
10
Please enter the width of room number 2 (in feet):
15.5
Please enter the length of room number 2 (in feet):
23
Are the walls textured? (Y or N)
Y
Do you have to enter another room? (Y or N)
N
The system will then ask the user which type of paint that they will use; the paint will be one of three categories: Builder-grade, Contractor-grade, or Premium-grade. They will be priced as follows:
Builder-grade = $13/gallon
Contractor-grade = $22/gallon
Premium-grade = $35/gallon
The system will then output how much paint will be needed for the job, and how much that paint is going to cost.
Also if possible write a brief algorithm and comments on the code to explain the variables.
Explanation / Answer
import java.util.Scanner;
public class PaintJob
{
public static void main(String[] args)
{
double Height,Width,Length;
int i=1;
String str;
char choice;
Scanner keyboard = new Scanner(System.in);
System.out.println("Are the walls textured? (Y or N)");
str = keyboard.nextLine();
choice=str.charAt(0);
System.out.println("Please enter the height of room number " + i +" (in feet):");
Height = keyboard .nextDouble();
System.out.println("Please enter the width of room number " + i +" (in feet):");
Width = keyboard .nextDouble();
System.out.println("Please enter the length of room number " + i +" (in feet):");
Length = keyboard .nextDouble();
switch(choice )
{
case 'y':
case 'Y':
textured(Height,Width,Length);
break;
case 'n':
case 'N':
nontextured(Height,Width,Length);
break;
default:
System.out.println("Invalid choice.");
}
}
public static void textured(double Height,double Width,double Length )
{
double sf,gal,total;
sf = (Height * Width * Length );
Scanner keyboard = new Scanner(System.in);
System.out.println(" Please enter which type of paint will you use: 1.Builder-grade 2. Contractor-grade 3. Premium-grade ");
int painttype = keyboard .nextInt();
switch(painttype)
{
case 1:
gal = (sf/200);
total = (gal * 13);
System.out.println("Total " + gal + "gallon paint is needed and the total cost is:" + total);
break;
case 2:
gal = (sf/200);
total = (gal * 25);
System.out.println("Total " + gal + "gallon paint is needed and the total cost is:" + total);
break;
case 3:
gal = (sf/200);
total = (gal * 35);
System.out.println("Total " + gal + "gallon paint is needed and the total cost is:" + total);
break;
default:
System.out.println("Invalid choice.");
}
}
public static void nontextured(double Height,double Width,double Length)
{
double sf,gal,total;
sf = (Height * Width * Length );
Scanner keyboard = new Scanner(System.in);
System.out.println(" Please enter which type of paint will you use: 1.Builder-grade 2. Contractor-grade 3. Premium-grade ");
int painttype = keyboard.nextInt();
switch(painttype)
{
case 1:
gal = (sf/350);
total = (gal * 13);
System.out.println("Total " + gal + "gallon paint is needed and the total cost is:" + total);
break;
case 2:
gal = (sf/350);
total = (gal * 25);
System.out.println("Total " + gal + "gallon paint is needed and the total cost is:" + total);
break;
case 3:
gal = (sf/350);
total = (gal * 35);
System.out.println("Total " + gal + "gallon paint is needed and the total cost is:" + total);
break;
default:
System.out.println("Invalid choice.");
}
}
}
I hope this will helps to You !
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.