Can someone tell what I am doing wrong. My totals is not coming in for hours of
ID: 3646982 • Letter: C
Question
Can someone tell what I am doing wrong. My totals is not coming in for hours of labor required and my other total is coming in at 0. How to do I do the input validation.A painting company has determined that for every 115 square feet or 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:
* The number of gallons of paint required
* The hours of labor required
*The cost of the paint
*The labor charges
*The Total cost of the paint job
Input validation: Do not accept a value less than 1 for the number of rooms. Do not accept a value less than $10.00 for the price of paint. Do accept a negative value for square footage of wall space.
This what I came up with :
Public Class Form1
' Define Constants.
Const dblWallSpace As Double = 115
Const dblGallonOfPaint As Double = 1
Const dblLaborRequired As Double = 8
Const dblLaborCostPerHour As Double = 18.0
Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click
'Declare variables.
Dim intNumberGallonsOfPaintRequired As Integer
Dim dblHoursOfLaborRequired As Double
Dim dblCostOfThePaint As Double
Dim dblLaborCharges As Double
Dim dblTotalCostOfThePaint As Double
Dim dblNumberOfRoomsPainted As Double
Dim dblPriceOfThePaintPerGallon As Double
Dim strInput As String
Dim dblPaintCost As Double
'Display the total wall space.
strInput = ("Enter the total wall space to be painted in square units:")
lblNumberOfGallonsOfPaintRequired.Text = CStr(dblWallSpace)
'Display Number of Gallons of paint.
intNumberGallonsOfPaintRequired = CInt(dblWallSpace)
lblLaborCharges.Text = CStr(8 * dblWallSpace)
lblCostOfThePaint.Text = CStr(dblPaintCost * dblWallSpace)
lblLaborCharges.Text = CStr(18 * dblHoursOfLaborRequired )
lblTotalCostOfThePaintJob.Text = CStr(dblTotalCostOfThePaint + dblLaborCharges)
End Sub
Explanation / Answer
Learn to do it next time. You'll understand it better by doing it yourself import javax.swing.JOptionPane; public class PSlab5PaintingCompany { private static int SizeToCost = 115; // Cost calculated per 115 squared feet private static int PaintToCost = 1; // 1 gallon of paint used per 115 squared feet private static int LabourToCost = 8; // 8 hours to paint per 115 squared feet private static int LabourCostPerHour = 18; // Labour cot per hour public static void main(String[] args) { // -------------- // Get user input // -------------- //Get the user input of square feet. double RoomSize = getDouble("Enter size of each room (in squared feet): "); //Get the user's input on gallons of paint needed double PaintCost = getDouble("Enter price of paint per gallon: "); //Get the user's input on gallons of paint needed double RoomCount = getDouble("Enter number of rooms to paint: "); // ------------------------ // Now, do our calculations // ------------------------ // Calc. how many of 115 sq. feet blocks is there double RoomCostUnit = (RoomSize * RoomCount) / SizeToCost; // The number of gallons of paint required double PaintCountTotal = PaintToCost * RoomCostUnit; //2. The hours of labor required double LabourCountTotal = LabourToCost * RoomCostUnit; //3. The cost of the paint double PaintCostTotal = PaintCountTotal * PaintCost; //4. The labor charges double LabourCostTotal = LabourCountTotal * LabourCostPerHour; //5. The total cost of the paint job double JobCostTotal = PaintCostTotal + LabourCostTotal; // --------------- // Display results // --------------- double DisplayPaintCountTotal = (double)((int)(PaintCountTotal * 100) / 100.0); double DisplayLabourCountTotal = (double)((int)(LabourCountTotal * 100) / 100.0); double DisplayPaintCostTotal = (double)((int)(PaintCostTotal * 100) / 100.0); double DisplayLabourCostTotal = (double)((int)(LabourCostTotal * 100) / 100.0); double DisplayJobCostTotal = (double)((int)(JobCostTotal * 100) / 100.0); String Message = "The number of gallons of paint required = " + DisplayPaintCountTotal + " " + "The hours of labor required = " + DisplayLabourCountTotal + " " + "The cost of the paint = " + DisplayPaintCostTotal + " " + "The labor charges = " + DisplayLabourCostTotal + " " + "The total cost of the paint job = " + DisplayJobCostTotal + " "; JOptionPane.showMessageDialog(null, Message); } private static double getDouble (String Prompt) { //System.out.print(Prompt); //Scanner InFile = new Scanner(System.in); //String UserInput = InFile.nextLine(); String UserInput = JOptionPane.showInputDialog(Prompt); return ((double)Double.parseDouble(UserInput)); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.