Having problem returning amount from method

getting this error when i compile,cant figure out why...... thx for help
Prog4.java:57: '.class' expected
                    double prem_bill = premium_bill(int day, int night);
^
Prog4.java:57: ')' expected
                    double prem_bill = premium_bill(int day, int night);
String name, input;
          char serv_code;
          int acct_num, day_mins, night_mins;
          for (int count = 1; count <= 5; count++)               //looping construct-will run 5 times
               //Get name
               name = JOptionPane.showInputDialog("What is your name?");
               //Get acct_num
               input = JOptionPane.showInputDialog("What is your account number?");
               //Convert input to integer
          acct_num = Integer.parseInt(input);
               //Get serv_code                                                  
               input = JOptionPane.showInputDialog("Service code? (R-Regular, P-Premium)");     
               serv_code = input.charAt(0);          
               //Validate serv_code
                    while ((serv_code != 'R') && (serv_code != 'r') && (serv_code != 'P') && (serv_code != 'p'))
                         input = JOptionPane.showInputDialog("Error. (R-Regular, P-Premium)");     
                         serv_code = input.charAt(0);     
               //Get minutes
                    if (serv_code == 'R' || serv_code == 'r')
                         input = JOptionPane.showInputDialog("How many minutes were used in the day?");
                         day_mins = Integer.parseInt(input);               
                         regular_bill(day_mins);
                    double reg_bill = regular_bill(day_mins);
               //Display output(regular)
                         System.out.println("Hello " + name + ".");
                         System.out.println("Your account number is " + acct_num + ".");
                         System.out.println("Your service type is " + serv_code + ".");
                         System.out.println("Number of minutes used was " + day_mins + ".");
                         System.out.println("Your total is " + reg_bill + ".");
                    else
                         input = JOptionPane.showInputDialog("How many minutes were used in the day?");
                         day_mins = Integer.parseInt(input);
                         input = JOptionPane.showInputDialog("How many minutes were used in the night?");
                         night_mins = Integer.parseInt(input);
                         premium_bill(day_mins, night_mins);
                         int total_mins = day_mins + night_mins;
                    double prem_bill = premium_bill(int day, int night);
               //Display output (premium)
                         System.out.println("Hello " + name + ".");
                         System.out.println("Your account number is " + acct_num + ".");
                         System.out.println("Your service type is " + serv_code + ".");
                         System.out.println("Number of minutes used was " + total_mins + ".");
                         System.out.println("Your total is " + prem_bill + ".");
     public static double regular_bill(int day)
          double result;          //Local variable
               if (day > 50)
                    result = (((day - 50) * .2) + 10);
               else
                    result = 10;
               return result;
     public static double premium_bill(int day, int night)
          double result, day_total, night_total;          //Local variables
               if (day > 75)
                    day_total = (((day - 75) * .1) + 10);
               else
                    day_total = 25;
               if (night > 100)
                    night_total = (((night - 100) * .05) + 10);
               else
                    night_total = 25;
                    result = (day_total + night_total);
               return result;
}

My quess is that you are trying to build a Customer-like class. I suggest that you should have two seperate classes. A Customer class, in which the constractor of the customer and the methods of the class should be located. Secondly you should implement a CustomerTester class, from which you can constract a new Customer object and call the methods you want. This has helped me a lot. In the tester class you can call the methods of your newly constructed object like: myCustomer.prenium_bill();
As mentioned post your code accordingly so people here can help you                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • I am having problems moving music from my computer to my IPhone.

    I am having problems moving music from my library to my IPhone. I have everything marked properly and it still won't move to my phone. Any suggestions?

    What exactly happens when you try to sync?
    Was the iPod previous synced to another iTunes library/computer?
    Have you successfully synced from this iTunes library/computer before?
    If so have you done anything like update iTunes on the computer since it last successfully synced?
    Do the songs play in iTunes?          
    Does any media now sync to the iPod?
    Do you have the right boxes checked to sync?
    iTunes: Syncing media content to iOS devices and iPod       
    Try syncing using the manual method                
    Managing content manually on iPhone, iPad, and iPod

  • Hi I am having problems removing mail from trash folder. Can anyone help please

    Hi I am having problems removing mail from trash folder. I can send mails to the folder but cannot delete them permanently from the trash folder. I am using Iphone 3G and anm up to date with OS. Can anyone help please

    Check that there isn't a different Trash folder to the one with the proper Trash symbol on it.
    If you see one in your list of folders rather than a separate one, highlight it, then click on Mailbox...Use this mailbox for...Trash

  • Why am i having problems since changing from snow leopard loading maverick

    why am i having problems since changing from snow leopard downloading maverick

    Yes you solved your own question, use printer handles color, whcih shodul have been the default. If you do want to experiment with Photohsop manages color, try the CMYK profiles, and send a cmyk file. Only exception is if you print to one of the few RGB printers like a lambda.

  • I am having problemes opening attachments from adobe reader.  I'm getting error 1606 (an internal error).  Plz HELP!

    I am having problems opening attachments from adobe reader.  I'm getting error 1606 (internal error).  PLZ HELP!

    <http://kb2.adobe.com/cps/402/kb402867.html> might help.

  • TS3276 Anyone having problems sending mail from Os X10.7.2?

    Anyone having problems sending mail from Os X10.7.2?
    i have Mac book pro,  I mac Desk top and i pad:All can receive mail but not send. I have checked and re checked set up etc No luck
    Thx

    Hi Ernie,
    Sorry I don't understand the first question :{
    Connection Doctor says everything is connected. i can send mail from the server's own web site ,just not from the Apple Mail program.
    The problem did begin when I was travelling from one hotel to another.
    Any ideas?
    Susan

  • I am on OS X and i am having problems sending pictures from the new pictures app via email.  when i hit the sharing button i have the option to send via iMessage or Facebook but the email option is ghosted and can't be checked off.  any suggestions?

    I am on OS X and i am having problems sending pictures from the new pictures app via email.  when i hit the sharing button i have the option to send via iMessage or Facebook but the email option is ghosted and can't be checked off.  any suggestions?

    I've resolved my problem now.  It wasn't iphoto: preferences:@ that I needed but iphoto:preferences:general where there is the option to choose email for sending photos.  Can't believe I missed that before.

  • Recently having problems receiving texts from my wife, but noone else that I am aware of. She is a Verizon as well

    recently having problems receiving texts from my wife, but no one else that I am aware of. She is a Verizon as well

    I'm very sorry for any trouble with messages, kmorr1. I'm determined to assist you in getting this resolved. Can you provide some details? What happens when you try to get messages from her? Which model device do you use? How about her device model? When did you first notice this?   DionM_VZW Follow us on Twitter @VZWSupport If my response answered your question please click the "Correct Answer" button under my response. This ensures others can benefit from our conversation. Thanks in advance for your help with this!!

  • TS3697 I'm having problems transferring photos from iphone to pc. any suggestions plz?

    I'm having problems transferring photos from iphone to pc. any suggestions plz?

    You should ask in the Apple Forum. This has nothing to do with Adobe Reader, which only reads PDF files.
    www.apple.com

  • Am having problems buying app from App Store ... It's not recognizing my credit card security code... It's says " incorrect code" any help pls wot do I do

    Am having problems buying app from App Store ... It's not recognizing my credit card security code... It's says " incorrect code" any help pls wot do I do

    This can be caused by a few things.
          Make sure the billing card address, the one on the statement is the exact
                 same as in iTunes.
          Note even the zip code being off can cause this.
           Try a different CC
          and the way the always works
              An iTunes GC.

  • Update to 10.6.3 and having problems returning from sleep mode

    Hi,
    Updated yesterday to 10.6.3 and having issues returning the laptop from sleep mode.
    I close the lid and the laptop goes to sleep but when opening the laptop I just get a blank screen. I can hear the hard drive start up but nothing is displayed on the screen and the sleep light is constantly on. Have tried various combinations of key presses to get it back but nothing works. I end up powering the laptop off in the end.
    Anyone else have this problem? Or know how to resolve it.
    I have run daily, weekly, monthly maintenance scripts, cleared system and user cache and repaired disk permission but I'm still getting the issue. I have a Time Machine backup but it dates back a month so I'm reluctant to restore.
    Cheers,
    Luke

    I'm having a similar problem that I may have cracked. My screen is on but the backlight is off (so the image is practically 100% on resume from hibernate. Have you reset the pram and cleared the smc?

  • Problem returning variables from dynamic SQL/PLSQL

    Hi, I have a problem I am trying to solve using a very short piece of dynamic SQL or PLSQL but I am having problems getting the variable values out of the dynamic block.
    I have 16 counters whose names are made up of three variable parts - 'scheme', 'contributory category' and 'employment category'
    The 'scheme' can be either 'no1', 'no2', 'off', 'cg' or 'amc'
    The 'contributory category' can be either 'cont' or 'noncont'
    The 'employment category' can be either 'ft' or 'pt'
    (There are only 16 because only 16 combinations are possible)
    For example the total counter name could be 'v_cg_noncont_ft_count'
    I have created a variable by concatenating the various elements called v_incr_count_name which holds the name of the counter I want to increment.
    I am running this whole thing within an anonymous PLSQL block so I cannot use global variables meaning that my variables are not visible within a dynamic PLSQL block.
    I believe this means that either I need to bind the variables within a PLSQL block or use a SELECT FROM INTO SQL block.
    I have tried a few solutions with no luck such as the following PLSQL:
    v_incr_count := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
    sql_stmt := 'BEGIN :a := :a + 1; END;';
    EXECUTE IMMEDIATE sql_stmt USING v_incr_count_name;
    Unfortunately I am getting the 'IN bind variable bound to an OUT position' error which I believe is because it is trying to return a value into v_incr_count_name which has been defined by default as an IN variable. The problem is that I need to store the returned value into the variable whose name is stored in v_incr_count_name.
    Another solution I tried is:
    v_incr_count_name := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
    sql_stmt := 'SELECT '||v_incr_count_name||' + 1 FROM DUAL';
    EXECUTE IMMEDIATE sql_stmt INTO v_return;
    This solution gives me an 'Invalid colum error'
    Any help would be greatly appreciated
    Cheers, Dan

    Repost:
    Problem with variables in dynamic SQL/PLSQL

  • Returning Values from Methods

    We ran across some code in one of our classes that calls a private method. That method returns an object, but the code calling that method does not capture it. What happens to the return value in a case like this? I would have thought that to be a syntax error.
    Example:
    myMethod(myObject, i);  // Call to myMethod without capturing its return value.
    private myObject myMethod(MyObject myObject, int i) {
       return myObject;
    }What happens to the return value from myMethod?

    (void) f(arg1, ..., argN); There's no
    provision in Java to allow you express that same
    intention.
    What?!?!?public void f(arg1, ...,
    argN);
    In the C code, function f was defined as having a non-void return type.
    The statement
    (void) f(arg1, ..., argN);shows the caller is knowing ignoring that returned value.

  • Having problems removing tags from script.

    I'm not using the browser to run Adobe Story, but the Desktop version from my iMac.  Cmd + Double Click works, but once every 30 times.  Is anyone else having this problem removing tags from a script?

    There are other ways to remove tags from a script
    From Tagging Panel:
    - Open Tagging Panel from View Menu
    - Click on Edit button. Here you have the option to delete individual tag-items or remove all from the scene.
    From File Menu
    - Open File - Tagging menu
    Here you will find the options to delete all/manually added/automatically added tags.

  • HT201253 How do I sync my iPad 2 to my iPhone 5? I'm having problems sending iMessages from my iPhone 5 to my iPad 2

    I Have an iPad 2 and an iPhone 5... I'm having problems iMessaging between the two devices...my iPad 2 is not getting any messages/ pictures sent from my iPhone 5.  I am also unable to sync them...
    Can anyone help?

    Hello, Deb2015.  
    Thank you for visiting Apple Support Communities.  
    I understand that messages sent and received from your iPhone are not showing up on your iPad.  I would check to make sure you have an internet connection on the iPad as this could be the cause.  If the issue persists, try the troubleshooting steps in the article below.  
    If you can't send or receive messages on your iPhone, iPad, or iPod touch
    Cheers, 
    Jason H.  

Maybe you are looking for

  • Set default permissions for new files?

    We have a small LAN where different users often need to open and resave each others' files. No server, just a bunch of client computers on ethernet sharing an internet router. Each time a user creates a file, that file's permissions default to read o

  • Mistake creating an Image Map

    Hello, I have a problem with my Image Map. Here are my steps: 1.Create areas for the Image Map 2.Create the Image Map with areas 3.upload the image 4.create the OTH file 5.Enable rendering information option 6.Create KM navigation iView and its layou

  • How embed 'clean' ID and password in Muse Secure Area sign-in works, but looks VERY klunky

    I built the website for a charitable organization of local business people who pump a lot of money back into youth-related activities in the local area.  They wanted a Secure Area so members could access other member phones, addresses, and other pers

  • Cannot Import .docx files

    We have servaral machine that used to be able to import .docx files and now no longer can.  When we choose create new pdf from file and choose a  *.docx we get this error: "Additional files will need to be installed to create PDF from this file. Do y

  • Aperture trial version

    hello ! so I'm wondering if there is some "bugs" or not in the aperture trial version (1.5.2) To me, the searching daesn't work at all, and same in the path correcting... I known my PB G4 17 got old but is that all ? Message was edited by: laffy