Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8201621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:52:41+00:00 2026-06-07T06:52:41+00:00

I’m currently writing a program where I have a string of methods all set

  • 0

I’m currently writing a program where I have a string of methods all set up basically identical. If they’re given i = 1, they’ll return the price of the product times the quantity ordered. Otherwise, they simply returned the quantity ordered. Whenever I attempt to compile it, however, the compiler says that the brackets are missing return statements. I’ve gone through the code several times and I don’t see anything overtly wrong in the syntax. Any guesses as to why this is happening?

Thank you for any help.

Relevant Source:

private class ButtonListener implements ActionListener {
        public void actionPerformed(ActionEvent e)
        {
            if (e.getSource() == switchCard)
            {
                cl.show(infoPanel, (String)candyList.getSelectedValue());
            }

        if (e.getSource() == checkoutButton)
        {
            double acidPops = acidPopsTotal(1);
            double bertieBotts = bertieBottsTotal(1);
            double bloodPops = bloodPopsTotal(1);
            double cauldronCakes = cauldronCakesTotal(1);
            double charmChoc = charmChocTotal(1);
            double chocoballs = chocoballsTotal(1);
            double chocCauldrons = chocCauldronsTotal(1);
            double chocFrogs = chocFrogsTotal(1);
            double chocWands = chocWandsTotal(1);
            double roachClusters = roachClustersTotal(1);
            double crystalPineapple = crystalPineappleTotal(1);
            double droobleGum = droobleGumTotal(1);
            double explodeBonbons = explodeBonbonsTotal(1);
            double fizzWhiz = fizzWhizTotal(1);
            double iceMice = iceMiceTotal(1);
            double jellySlugs = jellySlugsTotal(1);
            double liquorWands = liquorWandsTotal(1);
            double pepImpts = pepImpsTotal(1);
            double pinkIce = pinkIceTotal(1);
            double shockChoc = shockChocTotal(1);
            double spindleSpiders = spindleSpidersTotal(1);
            double quills = quillsTotal(1);
            double wizochoc = wizochocTotal(1);
        }
    }

    double acidPopsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (5.95* (Integer.parseInt(acidPopsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(acidPopsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double bertieBottsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (16.95 * (Integer.parseInt(bertieBottsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(bertieBottsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double bloodPopsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (5.95 * (Integer.parseInt(bloodPopsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(bloodPopsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double cauldronCakesTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (14.95 * (Integer.parseInt(cauldronCakesTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(cauldronCakesTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double charmChocTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (5.95 * (Integer.parseInt(charmChocTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(charmChocTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double chocoballsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (9.95 * (Integer.parseInt(chocoballsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(chocoballsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double chocCauldronsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (14.95 * (Integer.parseInt(chocCauldronsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(chocCauldronsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double chocFrogsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (14.95 * (Integer.parseInt(chocFrogsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(chocFrogsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double chocWandsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (9.95 * (Integer.parseInt(chocWandsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(chocWandsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double roachClustersTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (5.95 * (Integer.parseInt(roachClustersTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(roachClustersTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double crystalPineappleTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (9.95 * (Integer.parseInt(crystalPineappleTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(crystalPineappleTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double droobleGumTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (2.95 * (Integer.parseInt(droobleGumTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(droobleGumTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double explodeBonbonsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (9.95 * (Integer.parseInt(explodeBonbonsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(explodeBonbonsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double fizzWhizTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (9.95 * (Integer.parseInt(fizzWhizTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(fizzWhizTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double iceMiceTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (5.95 * (Integer.parseInt(iceMiceTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(iceMiceTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double jellySlugsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (2.95 * (Integer.parseInt(jellySlugsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(jellySlugsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double liquorWandsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (9.95 * (Integer.parseInt(liquorWandsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(liquorWandsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double pepImpsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (4.95 * (Integer.parseInt(pepImpsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(pepImpsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double pinkIceTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (4.95 * (Integer.parseInt(pinkCocoIceTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(pinkCocoIceTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double shockChocTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (4.95 * (Integer.parseInt(shockChocTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(shockChocTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double spindleSpidersTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (4.95 * (Integer.parseInt(spindleSpidersTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(spindleSpidersTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double quillsTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (1.95 * (Integer.parseInt(sugarQuillsTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(sugarQuillsTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }

    double wizochocTotal(int i)
    {
        if (i == 1)
        {
            try
            {
                return (5.95 * (Integer.parseInt(wizochocTF.getText())));
            }
            catch (NumberFormatException e) {}
        }
        else
        {
            try
            {
                return Integer.parseInt(wizochocTF.getText());
            }
            catch (NumberFormatException e) {}
        }
    }
}

Errors:

C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:490: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:510: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:530: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:550: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:570: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:590: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:610: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:630: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:650: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:670: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:690: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:710: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:730: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:750: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:770: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:790: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:810: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:830: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:850: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:870: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:890: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:910: error: missing return statement
        }
        ^
C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java:930: error: missing return statement
        }
        ^
Note: C:\Users\Sam\Desktop\Java\4H 2012\ClientApp.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
23 errors
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:52:43+00:00Added an answer on June 7, 2026 at 6:52 am

    There is no return guaranteed due to your try-catch blocks.

    You might want to return a sentinel of 0 or -1 to show this.

    An example that may make this more clear:

    double acidPopsTotal(int i) {
        if (i == 1) {
            try {
                return (5.95* (Integer.parseInt(acidPopsTF.getText())));
            } catch (NumberFormatException e) {
                //Missing return - compile error
            }
        } else {
            try {
                return Integer.parseInt(acidPopsTF.getText());
            } catch (NumberFormatException e) {
                //Missing return - compile error
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.