Use Methods to create Paint Job Estimator

Problem:
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:
- 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
Then it should display the data on the screen.
This is what I have so far. I tried, but I do not know how should I do for methods. Please help me! Thank you.
import java.util.Scanner;
import java.text.DecimalFormat;
public class PaintJobEstimator
     public static void main(String[] args)
          int sizeOfWall = 115;                // Size of wall in
                                                  // each room is 115 ft^2.
          int gallon = 1;                         // 1 gallon to paint
                                                  // per 115 ft^2.
          int hoursOfLabor = 8;                // 8 hours to paint per
                                                  // 115 ft^2.
          int laborCostPerHour = 18;           // Labour cost per hour
                                                  // in each room
          // Create Scanner object for kb input.
          Scanner kb = new Scanner(System.in);
          // Create a DecimalFormat object.
          DecimalFormat formatter = new DecimalFormat("#0.00");
          // Questions to ask
          // Get the # of ft^2 of wall space in each room.
          System.out.print("Enter the number of wall space in " +
                              "each room (in square feet): ");
          double sizeToPaint = kb.nextDouble();
          // Get the # of rooms to be painted.
          System.out.print("Enter the number of rooms " +
                              "to be painted: ");
          double numberOfRooms = kb.nextDouble();
          // Get the price of the paint per gallon.
          System.out.print("Enter the price of the paint " +
                              "per gallon: ");
          double priceOfPaint = kb.nextDouble();
          // Calculate how many of 115 ft^2 block is there.
          double roomCostUnit
               = (sizeToPaint * numberOfRooms)/sizeOfWall;
          // Call method.
                // I think I have to have Methods here... but I do not know.
          // Calculation
          //1. Calculate the # of gallons of paint required.
          double numberOfGallons = gallon * roomCostUnit;
          //2. Calculate the hours of labor required.
          double hoursRequired = hoursOfLabor * roomCostUnit;
          //3. Calculate the cost of the paint.
          double paintCostTotal = numberOfGallons * priceOfPaint;
          //4. The labor charges.
          double laborCostTotal = hoursRequired * laborCostPerHour;
          //5. The total cost of the paint job.
          double jobCostTotal = paintCostTotal + laborCostTotal;
          

I fixed. I replaced calculations things, and it seems good... Could you check it?
Thank you!
import java.util.Scanner;
import java.text.DecimalFormat;
public class PaintJobEstimator
     public static void main(String[] args)
          int sizeOfWall = 115;                // Size of wall in
                                                  // each room is 115 ft^2.
          int gallon = 1;                         // 1 gallon to paint
                                                  // per 115 ft^2.
          int hoursOfLabor = 8;                // 8 hours to paint per
                                                  // 115 ft^2.
          int laborCostPerHour = 18;           // Labour cost per hour
                                                  // in each room
          // Create Scanner object for kb input.
          Scanner kb = new Scanner(System.in);
          // Create a DecimalFormat object.
          DecimalFormat formatter = new DecimalFormat("#0.00");
          // Questions to ask
          // Get the # of ft^2 of wall space in each room.
          System.out.print("Enter the number of wall space in " +
                              "each room (in square feet): ");
          double sizeToPaint = kb.nextDouble();
          // Get the # of rooms to be painted.
          System.out.print("Enter the number of rooms " +
                              "to be painted: ");
          double numberOfRooms = kb.nextDouble();
          // Get the price of the paint per gallon.
          System.out.print("Enter the price of the paint " +
                              "per gallon: ");
          double priceOfPaint = kb.nextDouble();
          // Calculate how many of 115 ft^2 block is there.
          double roomCostUnit
               = (sizeToPaint * numberOfRooms)/sizeOfWall;
          // Calculation:
          //1. The number of gallons of paint required
               double numberOfGallons = gallon * roomCostUnit;
          //2. Calculate the hours of labor required.
               double hoursRequired = hoursOfLabor * roomCostUnit;
          //3. Calculate the cost of the paint.
               double paintCostTotal = numberOfGallons * priceOfPaint;
          //4. The labor charges.
               double laborCostTotal = hoursRequired * laborCostPerHour;
          //5. The total cost of the paint job.
               double jobCostTotal = paintCostTotal + laborCostTotal;
          // Call methods and display
          // Call cal1 method
          double ans1 = cal1(gallon, roomCostUnit);
          // Display
          System.out.println("The number of gallons of "
                              + "paint required: " +
                              formatter.format(ans1));
          // Call cal2 method
          double ans2 = cal2(hoursOfLabor, roomCostUnit);
          // Display
          System.out.println("The hours of labor " +
                              "required: " +
                              formatter.format(ans2));
          // Call cal3 method
          double ans3 = cal3(numberOfGallons, priceOfPaint);
          //Display
          System.out.println("The cost of the paint: "
                              + formatter.format(ans3));
          // Call cal4 method
          double ans4 = cal4(hoursRequired, laborCostPerHour);
          // Display
          System.out.println("The labor charges: "
                              + formatter.format(ans4));
          // Call cal5 method
          double ans5 = cal5(paintCostTotal, laborCostTotal);
          // Display
          System.out.println("The total cost of the " +
                              "paint job: " +
                              formatter.format(ans5));
     // cal1 method
     public static double cal1(double Gallon, double Room_Cost_Unit)
          double result;
          result = Gallon * Room_Cost_Unit;
          return result;
     // cal2 method
     public static double cal2(double Hours_Of_Labor, double Room_Cost_Unit)
          double result;
          result = Hours_Of_Labor * Room_Cost_Unit;
          return result;
     // cal3 method
     public static double cal3(double Number_Of_Gallons, double Price_Of_Paint)
          double result;
          result = Number_Of_Gallons * Price_Of_Paint;
          return result;
     // cal4 method
     public static double cal4(double Hours_Required, double Labor_Cost_Per_Hour)
          double result;
          result = Hours_Required * Labor_Cost_Per_Hour;
          return result;
     // cal5 method
     public static double cal5(double Paint_Cost_Total, double Labor_Cost_Total)
          double result;
          result = Paint_Cost_Total + Labor_Cost_Total;
          return result;
}

Similar Messages

  • Can I use Illustrator CS2 create this job ?

    This job use CS5 ;
    http://vector.tutsplus.com/tutorials/designing/how-to-create-a-vector-illustration-and-pre pare-it-for-micro-stock-sale/
    But I use CS2, Can I do like above job?

    I suggest you ask in the Illustrator forum.
    Illustrator forum.

  • Use Captivate to create PDF Manuals

    We have been research "single-source authoring" solutions, such as Datango, uPerform, STT Trainer, UPK, etc.  They promote the ability to capture screenshots and generate Job Aids, Videos, Sims, and EPSS resources with a single click. 
    My Q - Has anyone used Captivate to create handouts / job aids?  I played around with a few of the Print publishing outputs, and I don't think we can use them.
    If you have used it, it would be very helpful to see an example of a job aid that you created.
    Until I find a way to do it, I'm taking one of the print publish outputs and significantly modifying them to look like our current quick reference guides.
    Thanks!
    Micky

    Hi Micky
    mickyfokken wrote:
    ...I hope my days of manually pasting screenshots into word documents are over.
    I'm not sure they are.
    Captivate allows you to record what is happening. For example, perhaps you are describing how to open Windows Character Map. You Start Captivate, define your recording area and set about opeingin Windows Character Map. Then you stop recording. Captivate will have captured the screens that were involved. You would see a screen of the desktop with the mouse moving to the Start button. Another screen where the Start button is clicked. Another screen where the mouse moves to the Run command and clicks. Another screen where you see charmap being typed into the field and Enter is pressed to launch the application. That would be the Captivate project. You would thien tell Captivate you wanted to create a SWF of that.
    With RoboHelp, you create HTML pages which are known as Topics. And you might also describe the same process of opening Character Map in one or more topics. Much like Word, you would type information in and capture screen shots. (Possibly using RoboScreen Capture if you like). But each screen capture would need to still be inserted into the topic(s). No way around that, I'm afraid.
    I'm unfamiliar with how Frame works. To me it's bewildering. So I'd have to leave it to others to describe that to you. But I do believe it works in a similar manner to RoboHelp, in that you type your information into it. Frame simply handles very large documents more easily. It also stores and arranges the content differently.
    Hopefully I've helped more than hindered here... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • How to use an object's paint method

    I have created a class imagePanel which extends a jPanel to display an image. When I create a new imagePanel object I pass it an image argument which is used to paint my image on the jPanel, so far so good. I don't wish to have to continuously create new ImamePanels to display new images so I thought I could make a set_Image method that would set a new image in an exising imagePanel object. This is where I run into problems how to use the existing object paint method to replace the image. I tried this without success:
    public Image setMyImage (Image myImage)
    imageX = myImage; // imageX is the image that is painted by the imagePanel object's paint method
    paint(g);
    Something must be wrong on how I access the paint method. Thanks for any help.
    Jack

    Yahoooo, got it. This was the code I needed and thanks for your help:
    public void setImage (Image myImage)
    imageX = myImage;
    repaint(300);
    }

  • How to create search function (af:query) using method in java

    hi All..:)
    i got problem with search custom (af:query), how to create search function/ af:query using method in java class?
    anyone help me....
    thx
    agungdmt

    Hi,
    download the ADF Faces component demo sources from here: http://www.oracle.com/technetwork/testcontent/adf-faces-rc-demo-083799.html It also has an example for creating a custom af:query model
    Frank

  • How to call paint() method during creating object

    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    class SomeShape extends JPanel {
         protected static float width;
         protected BasicStroke line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
    class Oval extends SomeShape {
         Oval(float width) {
              this.width = width;
              line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
              repaint();
         public void paint(Graphics g) {
              Graphics2D pen = (Graphics2D)g;
              int i = 10;
              super.paint(g);
                   g.setColor(Color.blue);
                   g.drawOval(90, 0+i, 90, 90);
                   System.out.println("paint()");
    public class FinalVersionFactory {
        JFrame f = new JFrame();
        Container cp = f.getContentPane();
        float width = 0;
        SomeShape getShape() {
             return new Oval(width++); //I want to paint this oval when I call getShape() method
         public FinalVersionFactory() {
              f.setSize(400, 400);
    //          cp.add(new Oval()); without adding
              cp.addMouseListener(new MouseAdapter() {
                   public void mouseReleased(MouseEvent e) {
                        getShape();
              f.setVisible(true);
         public static void main(String[] args) { new FinalVersionFactory(); }
    }I need help. When I cliked on the JFrame nothing happened. I want to call paint() method and paint Oval when I create new Oval() object in getShape(). Can you correct my mistakes? I tried everything...Thank you.

    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    class SomeShape extends JPanel {
         protected static float width;
         protected static BasicStroke line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
    class Oval extends SomeShape {
         static int x, y;
         Oval(float width, int x, int y) {
              this.width = width;
              this.x = x;
              this.y = y;
              line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
         public void paint(Graphics g) {
              Graphics2D pen = (Graphics2D)g;
                   g.setColor(Color.blue);
                   pen.setStroke(line);
                   g.drawOval(x, y, 90, 90);
                   System.out.println("Oval.paint()"+"x="+x+"y="+y);
    class Rect extends SomeShape {
         static int x, y;
         Rect(float width, int x, int y) {
              this.width = width;
              this.x = x;
              this.y = y;
              line = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND);
         public void paint(Graphics g) {
              Graphics2D pen = (Graphics2D)g;
                   g.setColor(new Color(250, 20, 200, 255));      
                   pen.setStroke(line);
                   g.drawRect(x, y, 80, 80);
                   System.out.println("Rect.paint()"+"x="+x+"y="+y);
    public class FinalVersionFactory extends JFrame {
        Container cp = getContentPane();
        float width = 0;
        int x = 0;
        int y = 0;
            boolean rect = false;
        SomeShape getShape() {
             SomeShape s;
              if(rect) {
                   s = new Rect(width, x, y);
                   System.out.println("boolean="+rect);
              } else {
                   s = new Oval(width++, x, y);
                   System.out.println("boolean="+rect);
              System.out.println("!!!"+s); //print Oval or Rect OK
              return s; //return Oval or Rect OK
         public FinalVersionFactory() {
              setSize(400, 400);
              SomeShape shape = getShape();
              cp.add(shape); //First object which is add to Container(Oval or Rect), returned by getShape() method
              //will be paint all the time. Why? Whats wrong?
              cp.addMouseListener(new MouseAdapter() {
                   public void mouseReleased(MouseEvent e) {
                        x = e.getX();
                        y = e.getY();
                        rect = !rect;
                        getShape();
                        cp.repaint(); //getShape() return Oval or Rect object
                                      //but repaint() woks only for object which was added(line 67) as first
              setVisible(true);
         public static void main(String[] args) { new FinalVersionFactory(); }
    }I almost finish my program but I have last problem. I explained it in comment. Please look at it and correct my mistakes. I will be very greatful!!!
    PS: Do you thing that this program is good example of adoption Factory Pattern?

  • Why we are using event receivers in creating timer jobs?

    Hi All,
    Why we are using event receivers in creating timer jobs?
    Thanks in advance!

    Hi,
    Suppose you are creating a custom timer job following the steps which are similar as what this demo provides:
    http://www.codeproject.com/Articles/403323/SharePoint-Create-Custom-Timer-Jobs
    In this demo, an Event Receiver is created for installing the Job Definition when we deploy the solution or uninstalling it when we extract this solution.
    Here, the Event Receiver listens to the FeatureActivated evetn and the FeatureDeactivating event, which corresponding to the timing of activating and deactivating the feature
    of this solution, it just like a switch during the life cycle of a solution in a SharePoint site collection which will make us easier to manage the features coming with a solution package.
    More information about feature and solution:
    http://msdn.microsoft.com/en-us/library/office/aa543214(v=office.14).aspx
    https://www.simple-talk.com/dotnet/.net-tools/using-features-and-solutions-to-deploy-your-sharepoint-customizations/
    Feel free to reply if this is not what your question about or there are still any questions.
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • How to use Synchronized method when creating our own controls

    I don't know how to use the synchronized method when creating our own activex like controls to speed up the application.

    [url http://java.sun.com/docs/books/tutorial/essential/threads/multithreaded.html] here you go 

  • Any way to find out which program has created a job using 'JOB_OPEN'?

    Hi,
    I have some jobs created by some program. The job is incomplete, i.e., the programs which created the job just used 'JOB_OPEN' and it doesn't have any steps.
    Is there any way to find out which program created that incomplete job?
    Thanks in advance.
    Regards,
    Arun Mohan

    Not sure but try this FM
    BP_JOB_SELECT -Returns a table with job(s) details .
    кu03B1ятu03B9к
    Edited by: kartik tarla on Dec 30, 2008 6:50 PM

  • Error While creating a Job using JOB_OPEN

    Hello,
    I am trying to create a job in the output type of a standard transaction.
    But the job creation is failing. While debugging the transaction in update mode, I found out that the JOB_OPEN is coming out in the 'COMMIT WORK'.
    Is there any other way to create a job so that the program executes properly.
    Thanis/Regards,
    Abhijit Anandgaonkar.

    Hi,
    create a RFC function module....and inside the function module...create the batch job..
    in the output type processing program...call the RFC function module in background task..
    Thanks
    Naren

  • When sp_add_log_shipping_primary_database Creates Alert job - why sp_add_log_shipping_alert_job ?

    Hi, 
    sp_add_log_shipping_primary_database created two jobs : 1. Backup Job 2.Alert Job . Why do we require sp_add_log_shipping_alert_job ? 
    Many Thanks
    Chaithanya M
    Regards Chaithu.. If it is usefull,Mark this as Answer.

    But Alert job is by default created when we run sp_add_log_shipping_primary_database . so, why we need this one
    : sp_add_log_shipping_alert_job  ?
    Regards Chaithu.. If it is usefull,Mark this as Answer.
    Hello,
    Ok sorry I did not got your point first time.You dont need to create an alert using this method as alert is already created(as you said) .This proc also checks to see if alert job is created ,if not created it will create it.So as you say its already created
    you dont need to run sp_add_logshipping_alert_job
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • OWB maping execution :- ORA-20213: Unable to create standalone job record

    Hi,
    When I am running an owb mapping from sqlplus, I am getting the following error:
    SQL> DECLARE
    2 RetVal NUMBER;
    3 P_ENV WB_RT_MAPAUDIT.WB_RT_NAME_VALUES;
    4 BEGIN
    5 RetVal := UII_D_MAP_SPC_WIPBIN.MAIN ( P_ENV );
    6 dbms_output.put_line('RetVal is '||RetVal);
    7 END;
    8 /
    DECLARE
    ERROR at line 1:
    ORA-20213: Unable to create standalone job record - there may be no task
    defined for this map
    ORA-06512: at "UII_OWB_REP.WB_RT_MAPAUDIT", line 1266
    ORA-06512: at "UII_OWB_REP.WB_RT_MAPAUDIT", line 2098
    ORA-06512: at "UII_ODS_OWNER.UII_D_MAP_SPC_WIPBIN", line 3851
    ORA-06512: at "UII_ODS_OWNER.UII_D_MAP_SPC_WIPBIN", line 3993
    ORA-06512: at line 5
    Previously, I had unregistered the target schema from "OWB Runtime Audit Browser" logging as a QA user and registered to a new schema from OWB DEPLOYMENT MANAGER.
    I am able to deploy the mapping from Owb Deployment Manager and the deployment goes OK.
    I have also gone through the links:
    OWB execution error : ORA-20213: Unable to create standalone job record
    Re: ORA-20213 during execution
    But, did not find the solution.
    When I execute the mapping from Owb Deployment Manager after right clicking on it, it is working fine. But, above execution method is not working.
    We want to run the mappings in the above way, because all our mappings in our other projects are running fine in the above sql run procedure.
    Can you please help me out, how to fix the above errors?
    Thanks & Regards,
    lenin

    Good morning Lenin,
    Since the other threads do not apply, you've gotten yourself into a strange situation.
    I'm not familiar with the method you use to run the mapping, have you tried running the mapping using the SQL-template that OWB provides or - like I do - the run_my_owb_stuff script provided by the OWB time? If not, could you try that please?
    Apart from that, I don't have any experience with your exact error message so it's hard to share anything concrete, I can only suggest things. Maybe there are other users on this forum that do, who knows...
    If you want concrete support, log a TAR with Metalink, they are obligated to help you if you have a CSI :-)
    Good luck, Patrick

  • How do I use the brush to paint in latest version of Photoshop CC ?  I have a MAC with OS 10.10.2

    How do I use the brush to paint in latest version of Photoshop CC ?  I have a MAC with OS 10.10.2. 
    I clicked the brush tool, then clicked on color swatch that brought me to the colors and clicked OL... but not able to get the color I need.

    Well if I follow him, he creates an Exposure Adjustment Layer.
    Then he cranks up the Exposure, lightening the entire body, which he does not want. It's only the head.
    So leaving the Exposure set to where he put it, he selects that adjustment layer, clicks on that white thumbnail mask first, then paints
    using the brush and black. What this does is "hides" or Masks the exposure effect where he paints, it doesn't paint the picture black.
    He finds having to "mask" the entire body a lot of work. So he changes the mask to black by inverting it, and changes the swatch to white.
    Then being sure the black mask thumbnail is selected, he paints the head with the white color, punching a hole in the mask so the exposure setting comes through on the face.
    Does that make sense?

  • Create Background Job after data saved in module

    Hello,
    I have a program that has a start selection screen with material group, you enter your data, execute.  When it has finished you get a ALV of sales order with items where you can make changes to dates and other details and save.  I would like to add a save in background option.  Is this possible? I assume it would be difficult because of the container.. it uses a bapi to save sale orders...
    The employees run this job which takes a little while.. at the end of the day.. they go home and of course SAP has timed out.  If they can run it in the background then no problem....
    Thanks,
    AJ

    well, you can pass the data from the same to an other program and submit it in background.
    Just create a job.
    CALL FUNCTION 'JOB_OPEN'
           EXPORTING
                jobname          = gv_jobname
           IMPORTING
                jobcount         = gv_jobcount
           EXCEPTIONS
                cant_create_job  = 1
                invalid_job_data = 2
                jobname_missing  = 3
                OTHERS           = 4.
      IF sy-subrc <> 0.
    *   no error required
      ENDIF.
    submit your program with job name and job count.
    CALL FUNCTION 'JOB_CLOSE'
           EXPORTING
                jobcount             = gv_jobcount
                jobname              = gv_jobname
                strtimmed            = 'X'
           EXCEPTIONS
                cant_start_immediate = 1
                invalid_startdate    = 2
                jobname_missing      = 3
                job_close_failed     = 4
                job_nosteps          = 5
                job_notex            = 6
                lock_failed          = 7
                OTHERS               = 8.
      IF sy-subrc <> 0.

  • Different methods of creating an XML Publisher report

    Hi All,
    Can anyone please advice me on different methods of creating an XML Publisher report.
    The method which we us is as follows -
    1. Create an RDF file and upload the same in the /REPORTS/US path.
    2. create a concurrent program, give output as XML.
    3. Create a data definition, but here we do not upload any data definition.
    4. Create a template and upload the RTF template.
    But I have heard that there is a method wherein we do not have to create the RDF and simply adding the query to the XML file works.
    But in that case do we upload anything in tht Data defition also ?
    Can anyone please provide me any link or some place where I can read about different methods to create an XML report without the use of an RDF.
    Regards,
    Shruti

    Hi Shruti,
    There is a method where we need not to create RDF as data defination. You need to write a xml file which we upload as data defination. The short name for this data defination used as short name as concurrent program having executable XDODTEXE.
    Sample XML data template :
    <?xml version="1.0" encoding="UTF-8" ?>
    <dataTemplate name="EmpData" description="Employee Details" version="1.0">
    <dataQuery>
    <sqlStatement name="Q1">
    <![CDATA[select business_group_id, business_group_name
                   from hrfv_business_groups
                   where date_to is null
                     and business_group_id not in (0, 82)
                         order by business_group_id]]>
    </sqlStatement>
    <sqlStatement name="Q2">
    <![CDATA[select employee_number,
                         title ,
                         full_name,
                         sex ,
                         date_of_birth,
                         email_address
                 from per_all_people_f
                 where business_group_id = :business_group_id
                   and current_employee_flag ='Y'
                   and trunc(sysdate) between effective_start_date and effective_end_date
                   and rownum<11]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_BG" source="Q1">
    <element name="BusinessGroupId" value ="business_group_id"/>
    <element name="BusinessGroupName" value ="business_group_name"/>
    <group name="G_EMP" source="Q2">
    <element name="EmpNumber" value ="employee_number"/>
    <element name="Title" value ="title"/>
    <element name="FullName" value ="full_name"/>
    <element name="Sex" value ="sex"/>
    <element name="DateOfBirth" value ="date_of_birth"/>
    <element name="EmailAddress" value ="email_address"/>
    </group>
    </group>
    </dataStructure>
    </dataTemplate>
    This data template generates xml data which prints output on rtf template.
    Hope this will help. Let me know for more info.

Maybe you are looking for