Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Java home utility calculator

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java home utility calculator

    So I am new to Java and trying to figure out this program, and my reading material for the class is sparse and not helpful. I mean that we have the bareist of information to go by. what I am trying to do is to: Write a Java™ GUI application using a NetBeans® IDE that does home utility auditing.
    The user should be able to do the following:
    • Enter the cost per kilowatt-hour.
    • Select from a list of 5 to 7 home appliances, which include a washer, among other appliances.
    • Enter the power needed in kilowatts (kW) for the selected appliance.
    • Enter the number of hours used per day for the selected appliance.
    • If the washer is selected, enter both the number of gallons of water used by the washer per hour and the cost per gallon.
    The program should do the following:
    • Validate that the data entered has the correct format, and is within a reasonable range.
    • Calculate and display the cost for operating a home appliance as soon as the data is entered.
    • Create a listing area to display each of the following for each appliance entered:
    o Home appliance
    o Number of hours per day
    o Cost
    • Display and update the total cost of all appliances, as soon as a new entry is added to the listing area.
    The Java™ application should meet these technical requirements:
    • The application should have at least one additional method, in addition to the application's controlling class (a controlling class is where the main function resides).
    • There should be proper documentation in the source code.

    And this is what I got so far... greeting panel.txtCheckBoxes.txtappliance class.txt
    Appliance Calculator bottom frame.txtTotals class.txtUserInput.txt

    Sorry so sloppy. Each file is a frame that will be added on to another but as you can see i have a lot of errors even though most of the coding I had gotten out of our reading material. so i am so confused.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,394
    Thanks
    49
    Thanked 2,212 Times in 2,185 Posts

    Default Re: Java home utility calculator

    Please post the code here and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    What specific questions do you have about your problems?

    Also if there are compiler errors, copy the full text and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java home utility calculator

    OK the first one is
    I am trying to make one JFrame with checkboxes to pick an appliance. This choice will fill in the text boxes in the totals frame with the correct information that the user supplies in the user input JFrame. every time i compile the code, the checkboxes will not add to the panel, just gives me erors.

     
    import java.awt.event.ActionEvent;
    import java.text.DecimalFormat;
    import javax.swing.BorderFactory;
    import javax.swing.JCheckBox;
     
    /**
     * to set the appliance, i will use checkboxes
     *pg 80 ch11 
     **/
    public class CheckBoxes
     
     
    {
     
    	//checkboxes for constants
    	private JCheckBox washer;
    	private JCheckBox dryer;
    	private JCheckBox fridge;
    	private JCheckBox stove;
    	private JCheckBox lights;
     
    	//Constructor
     
    	public CheckBoxes()
     
    	{
            public final double WASHER;
    	public final double DRYER;
    	public final double FRIDGE;
    	public final double STOVE;
    	public final double LIGHTS;
     
    	//gridlayout mgr- 4 rows 1 column
    	CheckBoxes(new GridLayout(4, 1);
     
    	//create the checkboxes
    	washer = new JCheckBox("Washer");
    	dryer = new JCheckBox("Dryer")
    	fridge = new JCheckBox("Fridge");
    	stove = new JCheckBox("Stove");
    	lights = new JCheckBox("Lights");
     
    	//add a border around the panel
    	setBorder(BorderFactory.createTitledBorder("Appliances"));
     
    	//add the checkboxes to the panel
    	add(washer);
    	add(dryer);
    	add(fridge);	
    	add(stove);
    	add(lights);
     
    	}
     
    		//method to get variables for each appliance
    	double total;           //variable to hold the total
     
    	//determine which appliance is selected
    	//more than one can be selected
    	if (washer.isSelected ())
    		total1 += kwhtxt * hourstxt + gallonstxt;
    	if (dryer.isSelected())
    		total1 += kwhtxt * hourstxt;
    	if (fridge.isSelected())
    		total1 += kwhtxt * hourstxt;
    	if (stove.isSelected())
    		total1 += kwhtxt * hourstxt;
    	if (lights.isSelected())
    		total1 += kwhtxt * hourstxt;
     
    	//return the total
    	return total1;
     
    		//this if loop will also combine the totals into one total
     
     
    	//add action listeners for the check boxes
    	washerJCheckBox.addActionListener (new washerJCheckBoxListener());
    	dryerJCheckBox.addActionListener (new dryerJCheckboxListener());
    	fridgeJCheckBox.addActionListener (new fridgeJCheckBoxListener());
    	stoveJCheckBox.addActionListener (new stoveJCheckBoxListener());
    	lightsJCheckbox.addActionListener (new lightsJCheckBoxListener());
     
    	//private inner class to handle the acton listeners
    	private class WasherJCheckBoxListener implements ActonListener
    	{
     
    	public void actionPerformed(ActionEvent e)
    	{
    		double kwhtxt;			//to hold the kwh variable
    		String s;			//to hold the name of the appliance
    		double hourstxt;		//to hold the hours variable
    		double gallonstxt;		//to hold the gallons variable (just for this one though)
    		double total1;			//to hold total
     
    		//calculate the total
     
     
     
    		total = total1;
     
    		DecimalFormat dollar = new DecimalFormat("0.00");
     
     
    /**
    * How do i make this pane the center of the computations, I mean I want a person to put in their 
    * user inputs on the left(WEST) pane, click an appliance on the center(CENTER) pane and automatically have the 
    * output show up on the right (I have not built it yet).
    * I am unsure about the action listeners and how to retrieve the info from another pane, I know htat i have to 
    * reference it, but cannot remember how to do that. HELP!
    *  I follows the directions in the reading but why so much red?
    * 
    **/ 
     
     
                }
            }
    }

    for example should nt i be able to make a 'dryer = new JCheckBox ("name");'?
    or add(checkbox);?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,394
    Thanks
    49
    Thanked 2,212 Times in 2,185 Posts

    Default Re: Java home utility calculator

    just gives me erors.
    Please copy the full text of the error messages and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java home utility calculator

    OK
    Updating property file: F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\build\built-clean.properties
    Deleting directory F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\build
    clean:
    init:
    deps-jar:
    Created dir: F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\build
    Updating property file: F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\build\built-jar.properties
    Created dir: F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\build\classes
    Created dir: F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\build\empty
    Created dir: F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\build\generated-sources\ap-source-output
    Compiling 6 source files to F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\build\classes
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\ApplianceCalculator.java:58: error: ';' expected
    exitButton.addActionListener (new ExitButtonListener()):
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:28: error: illegal start of expression
    public final double WASHER;
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:29: error: illegal start of expression
    public final double DRYER;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:30: error: illegal start of expression
    public final double FRIDGE;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:31: error: illegal start of expression
    public final double STOVE;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:32: error: illegal start of expression
    public final double LIGHTS;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:35: error: ')' expected
    CheckBoxes(new GridLayout(4, 1);
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:39: error: ';' expected
    dryer = new JCheckBox("Dryer")
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:61: error: illegal start of type
    if (washer.isSelected ())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:61: error: <identifier> expected
    if (washer.isSelected ())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:61: error: ';' expected
    if (washer.isSelected ())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:61: error: illegal start of type
    if (washer.isSelected ())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:62: error: ';' expected
    total1 += kwhtxt * hourstxt + gallonstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:62: error: <identifier> expected
    total1 += kwhtxt * hourstxt + gallonstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:62: error: <identifier> expected
    total1 += kwhtxt * hourstxt + gallonstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:62: error: <identifier> expected
    total1 += kwhtxt * hourstxt + gallonstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:63: error: illegal start of type
    if (dryer.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:63: error: <identifier> expected
    if (dryer.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:63: error: ';' expected
    if (dryer.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:63: error: illegal start of type
    if (dryer.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:64: error: ';' expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:64: error: <identifier> expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:64: error: <identifier> expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:65: error: illegal start of type
    if (fridge.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:65: error: <identifier> expected
    if (fridge.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:65: error: ';' expected
    if (fridge.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:65: error: illegal start of type
    if (fridge.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:66: error: ';' expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:66: error: <identifier> expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:66: error: <identifier> expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:67: error: illegal start of type
    if (stove.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:67: error: <identifier> expected
    if (stove.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:67: error: ';' expected
    if (stove.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:67: error: illegal start of type
    if (stove.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:68: error: ';' expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:68: error: <identifier> expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:68: error: <identifier> expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:69: error: illegal start of type
    if (lights.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:69: error: <identifier> expected
    if (lights.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:69: error: ';' expected
    if (lights.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:69: error: illegal start of type
    if (lights.isSelected())
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:70: error: ';' expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:70: error: <identifier> expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:70: error: <identifier> expected
    total1 += kwhtxt * hourstxt;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:73: error: illegal start of type
    return total1;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:73: error: ';' expected
    return total1;
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:79: error: <identifier> expected
    washerJCheckBox.addActionListener (new washerJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:79: error: illegal start of type
    washerJCheckBox.addActionListener (new washerJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:79: error: ')' expected
    washerJCheckBox.addActionListener (new washerJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:79: error: ';' expected
    washerJCheckBox.addActionListener (new washerJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:79: error: illegal start of type
    washerJCheckBox.addActionListener (new washerJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:79: error: <identifier> expected
    washerJCheckBox.addActionListener (new washerJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:80: error: <identifier> expected
    dryerJCheckBox.addActionListener (new dryerJCheckboxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:80: error: illegal start of type
    dryerJCheckBox.addActionListener (new dryerJCheckboxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:80: error: ')' expected
    dryerJCheckBox.addActionListener (new dryerJCheckboxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:80: error: ';' expected
    dryerJCheckBox.addActionListener (new dryerJCheckboxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:80: error: illegal start of type
    dryerJCheckBox.addActionListener (new dryerJCheckboxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:80: error: <identifier> expected
    dryerJCheckBox.addActionListener (new dryerJCheckboxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:81: error: <identifier> expected
    fridgeJCheckBox.addActionListener (new fridgeJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:81: error: illegal start of type
    fridgeJCheckBox.addActionListener (new fridgeJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:81: error: ')' expected
    fridgeJCheckBox.addActionListener (new fridgeJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:81: error: ';' expected
    fridgeJCheckBox.addActionListener (new fridgeJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:81: error: illegal start of type
    fridgeJCheckBox.addActionListener (new fridgeJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:81: error: <identifier> expected
    fridgeJCheckBox.addActionListener (new fridgeJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:82: error: <identifier> expected
    stoveJCheckBox.addActionListener (new stoveJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:82: error: illegal start of type
    stoveJCheckBox.addActionListener (new stoveJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:82: error: ')' expected
    stoveJCheckBox.addActionListener (new stoveJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:82: error: ';' expected
    stoveJCheckBox.addActionListener (new stoveJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:82: error: illegal start of type
    stoveJCheckBox.addActionListener (new stoveJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:82: error: <identifier> expected
    stoveJCheckBox.addActionListener (new stoveJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:83: error: <identifier> expected
    lightsJCheckbox.addActionListener (new lightsJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:83: error: illegal start of type
    lightsJCheckbox.addActionListener (new lightsJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:83: error: ')' expected
    lightsJCheckbox.addActionListener (new lightsJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:83: error: ';' expected
    lightsJCheckbox.addActionListener (new lightsJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:83: error: illegal start of type
    lightsJCheckbox.addActionListener (new lightsJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\CheckBoxes.java:83: error: <identifier> expected
    lightsJCheckbox.addActionListener (new lightsJCheckBoxListener());
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\TotalsPanel.java:36: error: illegal start of type
    public TotalsPanel ("Total")
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\UserInput.java:76: error: not a statement
    kwhField.getText; //retrieve text in kwh field
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\UserInput.java:102: error: illegal start of expression
    public double getHoursField()
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\UserInput.java:102: error: ';' expected
    public double getHoursField()
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\UserInput.java:135: error: illegal start of expression
    public double getgallonsField()
    ^
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\src\UserInput.java:135: error: ';' expected
    public double getgallonsField()
    ^
    82 errors
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\nbproject\build-impl.xml:923: The following error occurred while executing this line:
    F:\University of Phoenix\MSIS\CSS562 Programming Concepts\Java Code\Appliance Try4\nbproject\build-impl.xml:263: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 0 seconds)

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,394
    Thanks
    49
    Thanked 2,212 Times in 2,185 Posts

    Default Re: Java home utility calculator

    error: illegal start of expression
    Variables defined inside of a method or constructor can not be public.

    Many of the rest of the errors are because of misplaced {}s. Make sure the { and } are properly placed to enclose the statements in a method of constructor. Fixing the {}s will probably get rid of most of the errors.


    HINT: When typing in code, do a compile more often and fix the errors when there is a short list of errors.
    Don't type in too much code without doing a compile or you can get a long list of error messages like you have.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java home utility calculator

    Thank you I still have no Clue third Week of Java and im suppost to know this stuff

    --- Update ---

    Now htat I have the long list of errors, could you help me because i am still getting errors in the program. i do not understand why i cannont add a gridlayout or add a border around it

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,394
    Thanks
    49
    Thanked 2,212 Times in 2,185 Posts

    Default Re: Java home utility calculator

    Do as I suggested in the HINT. Start at the beginning and retype the code and compile every 10 lines or so, fix the errors and continue.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java Home Utility Auditing Program Netbeans calculations !
    By angelmg33 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: April 20th, 2014, 04:47 PM
  2. Replies: 0
    Last Post: July 24th, 2013, 02:09 AM
  3. JPF Utility program
    By newbie in forum The Cafe
    Replies: 5
    Last Post: December 25th, 2011, 05:34 AM
  4. Simple TCP utility failing right out the gate
    By Blackbird in forum Java Networking
    Replies: 2
    Last Post: July 8th, 2011, 08:30 AM