Is there any one who can help me solve this?

Hi.
I'm taking AP Computer Scinece AB in high school now.
I've been assigned many programs so far. But.. I can't figure them out.
There are two programs I need your help. So..Please!!!!!! Help Me!!!!
Please!! Enjoy helping me!
<Program #1>
It's divided into three small programs and I've figured out one of them, which was the easiest one..You will be able to see the programs if you click on the link below.
(page1)
http://iboard3.superboard.dreamwiz.com/board.cgi?db=90_darkoo&idx=2&page=1
(page2)
http://iboard3.superboard.dreamwiz.com/board.cgi?db=90_darkoo&idx=3&page=1
<Program #2>
http://iboard3.superboard.dreamwiz.com/board.cgi?db=90_darkoo&idx=4&page=1
The way I figured out first part of program #1 was like this :
public class ThreeX1
public static void main ( string[] org )
system.out.println ();
int startValue = 21;
int count = 0;
while (startValue >1)
count ++;
if (startValue % 2 == 0)
startValue = startValue/2;
else
startValue = 3*startValue +1;
system.out.println ( count );
===================================================
From there, for the second and third programs of program #1, I tried to figure it out by using 'for' statement instead of 'while', but I couldn't.
So..Please help me out.. Thank you
or you can e-mail me too. It would be great too.
add. : [email protected]

I probably shouldn't be doing your homework but here it is:
public class ThreeX2{
     public static void main ( String[] org ){
          int startValue = 2;
          while(startValue<100){
               System.out.print(startValue);
               System.out.print("\t");
               System.out.println(timesToGetToOne(startValue));
               startValue++;
     private static int timesToGetToOne(int intForValue){
          int count = 0;
          while (intForValue!=1){
               count ++;
               if (intForValue % 2 == 0)
                    intForValue = intForValue/2;
               else
                    intForValue = 3*intForValue +1;
          return count;
public class ThreeX3{
     public static void main ( String[] input ){
          int maximumTries = 1000000;
          int numberOfitterations = 10;
          try{
               numberOfitterations = new Integer(input[0]).intValue();
          }catch(Exception e){
          try{
               maximumTries = new Integer(input[1]).intValue();
          }catch(Exception e){
          int startValue = 2;
          while(startValue<maximumTries){
               if(timesToGetToOne(startValue)==numberOfitterations){
                    System.out.print("When startvalue is: ");
                    System.out.print(startValue);
                    System.out.print(" it will take exatly ");
                    System.out.print(timesToGetToOne(startValue));
                    System.out.println(" iterations to get to 1.");
                    // remove the next line and it will show all values that
                    // takes numberOfitterations amount of times to get to 1
                    break;
               startValue++;
     private static int timesToGetToOne(int intForValue){
          int count = 0;
          while (intForValue!=1){
               count ++;
               if (intForValue % 2 == 0)
                    intForValue = intForValue/2;
               else
                    intForValue = 3*intForValue +1;
          return count;
}Problem 3 is diffucult, since the input is one date I assume that the current reading is for this date. I don't
know the date of the previous reading so I cannot calculate if the consumption is between June through
Ocober.
your Main method shoud have 4 inputs date accountNumber currentReading previousReading
Your main function would look like this:
     public static void main ( String[] input ){
          Calendar date=null;
          int accountNumber = 0;
          int currentReading = 0;
          try{
               String[] s = input[0].split("/");
               date = Calendar.getInstance();
               date.set(Calendar.YEAR,new Integer(s[2]).intValue());
               date.set(Calendar.MONTH,new Integer(s[0]).intValue()-1);
               date.set(Calendar.DAY_OF_MONTH,new Integer(s[1]).intValue());
          }catch(Exception e){
               System.out.println("cannot get date, please start this program the following way: ");
               System.out.println("programName date(format mm/dd/yyyy) accountNumber currentReading previousReading");
          try{
               accountNumber = new Integer(input[1]).intValue();
          }catch(Exception e){
               System.out.println("cannot get account number, please start this program the following way: ");
               System.out.println("programName date(format mm/dd/yyyy) accountNumber currentReading previousReading");
          try{
               currentReading = new Integer(input[2]).intValue();
          }catch(Exception e){
               System.out.println("cannot get current reading, please start this program the following way: ");
               System.out.println("programName date(format mm/dd/yyyy) accountNumber currentReading previousReading");
          try{
               previousReading = new Integer(input[3]).intValue();
          }catch(Exception e){
               System.out.println("cannot get previous reading, please start this program the following way: ");
               System.out.println("programName date(format mm/dd/yyyy) accountNumber currentReading previousReading");
// check the date between june and oct:
// (5>date.get(Calendar.MONTH))&&(9<date.get(Calendar.MONTH))

Similar Messages

  • HI THERE!IS THERE ANY ONE WHO CAN HELP ME HAVING TROUBLE WITH MY IPHONE 3GS AFTER UPGRADING TO IOS5.0 IT WONT READ THE SIM AND NO SERVICE  AND IT WONT ACTIVATED.PLEASE HELP

    HI THERE IS THERE ANYONE WHO CAN HELP ME?I UPGRADE MY IPHONE 3GS TO IOS5 AND NOW IT WONT ACTIVATE AND SAYS THE SIM CARD IS NOT SUPPORTED I CHANGE FOR ANEW SIM ALREADY BUT STILL WONT ACTIVATE.PLEASE HELP

    you're responding to a post that's almost 2 months old. Time to post your own thread.

  • Since Ios 7 Update of my iPhone 5 I can not log into any WLAN any more - who can help to solve this major problem

    Hi all,
    I updated my iPhone 5 recently to IOS 7 - Since then I do not get any access to my home WLAN / WIFI with the iphone 5.
    At same time the iphone 3S and IPAD 1 of my wife (both IOS 5.x) still work fine in our homes WLAN / WIFI.
    Who can help to get my Iphone 5 with IOS 7 back to work in the home WIFI ?
    Thanks in advance for any possible solution.
    Best regards
    Dirk from Hamburg Germany

    Try this first.
    On the iPhone go to Settings > General > Reset and select Reset Network Settings.
    This will erase all saved wi-fi networks and settings.
    If no change after this, try resetting your modem and wireless router. Disconnect the router from the power source followed by disconnecting the modem from the power source. Wait a few minutes followed by powering your modem back on allowing it to completely reset before powering your wireless router back on allowing it to completely reset with the modem.

  • I have a CS3 Creativ Suite. - I have uninstalled it fram XP the corret way. Now i have installed Windows 7 and try to reinstall the creative suite. It accept the first CD an the serial number, but when i get to the second CD it stop. Any one who can help?

    I have a CS3 Creativ Suite. - I have uninstalled it fram XP the corret way. Now i have installed Windows 7 and try to reinstall the creative suite. It accept the first CD an the serial number, but when i get to the second CD it stop. Any one who can help?

    If you have Windows 7 Pro you can try to install CS3 in XP mode.

  • My new 3 month old imac 27 with 10.6.8 snow is giving a **** of noise from the fan. suddently starting after today starting up. and the volume buttoms and screen lights up and down not working any more.. any one who can help here???

    my new 3 month old imac 27 with 10.6.8 snow is giving a **** of noise from the fan. suddently starting after today starting up. and the volume buttoms and screen lights up and down not working any more.. any one who can help here???

    Try an SMC Reset. (System Management Controller)
    Shutdown>unplug from power for ten minutes>press and hold in the power button for ten seconds>startup again.
    Also try a PRAM Reset. (Parameter RAM)
    Shutdown. At the bootup chime, hold down CMD-Option-P-R together, wait for two more chimes, total three, then let go of all keys to finish booting,
    If this doesn't do it, run the Hardware Test in Extended
    http://support.apple.com/kb/ht1509

  • Error Message:"Cannot find or create the font 'WP-MathA'. Some characters may not display or print correctly."  Who can help me solve this problem?

    Some of the pdf files I work with (receive) come up with a comment: “Cannot find or create the font ‘WP-MathA’. Some characters may not display or print correctly.”  Who can help me solve this problem?
    Thank you in advance for  your time.
    Marlen

    Hello Anubha,
    I am having a similar problem on my machine.  I was using Word 2008 and I created a PDF inside Word.
    I am opening the file on the system itself and I am running Windows 8.1.  I am using Version 11 of Reader.
    When the PDF I created (my resume) attempts to open, it says:  cannot find or create the file Times, Bold.  Some characters may not display or print correctly. 
    However, the entire Reader keeps freezing and will not allow me to open or test print the document.  Also, it is not displaying any of the Bold Times New Roman Print.  Can you please help?  Thanks.

  • Hi hello...I have a problem deleting unwanted albums in my phone/photos, any one who can help me do it step by step please.Have patience with me I am not so good with this.

    Hi Hello,
         Before I start my question, hope nobody laugh at me, I am not a computer geek, I just a user of a phone.
    I have read so many how to do and how to delete albums in the web/google but not anyone of them make sense to me,I hope someone can help me do this step by step.
    I am using an iphone 4/operating system 7.0.4
    I would like to delete the unwanted albums in my phone under the photo icon, where do i start?
    like...   1/ connect the phone to the computer
                2/ click the itune icon
                3/ then whats next?
    Please help I could not download anyother app, the system( phone )  always tells me that memory is almost full, I am already frustrated, please help.
    If I reset the phone will it erase all the phone numbers and remove all my notes?
    Thank you.
    <Email Edited by Host>

    Hi mylenebar!
    Here is an article that will help you remove the desired photos from your phone:
    iTunes: Syncing photos
    http://support.apple.com/kb/ht4236
    To delete synced photos and videos from your device
    In iTunes, click the Device button in the upper right corner. (If viewing the iTunes Store, click the Library button in the upper-right corner first.)
    Click the Photos tab in the resulting window.
    Choose "Selected albums" and deselect the albums or collections you want to delete.
    Note: To delete all synced photos, deselect "Sync Photos from" and, when asked, click "Remove photos."
    Click Apply.
    Thanks for coming to the Apple Support Communities!
    Cheers,
    Braden

  • I can't download the apps with big size like need for spees, but in apps with normal size(less than 100KB)there is no problem,is there any body who can help me?

    I can't download the apps with big size like need for spees

    Have a little patience. 4 minutes is only a short time for someone to find your post and reply to it. Also clicking on "This Solved My Problem" marks your problem as solved so many folks that may otherwise help will pass the question by since it is "solved."
    I suggest you start a new question that gives a good title to a specific problem. Then in the body of the thread describe the problem in detail, tell us what steps you have tried so far to correct the problem, what happened, and what error messages you received.

  • I am extremely desperate any one who can help me!

    how do i do a flag or an alert on the server/system, so that when the user logs in they are notified that an email has been sent to them, and that they should check there inbox!
    All messages sent to the user will be stored in a mysql database, does this improve or hinder my query?
    All suggestions/solutions aill be gratefully appreciated!
    Thanks

    You question is a little vague... when you say "log in" are you referring to logging on to their workstation or logging on to a web application?
    If it is the latter, this could be done when their logon is validated. If the logon is valid, then execute a query that checks for any messages that have not yet been viewed plus any other logic you want to add....
    -Dave

  • Who can help to solve this question on MATERIALIZED VIEW and table?thanks

    Hi,dear all.
    If there is a MV with the same name as a table and they both exist in the same schema .
    e.g: MV : test123 and table : test123 (they have same name) exist in schema : schema123.
    when I run a sql : select * from schema123.test123; , what's the result of the execution?? MV or table which of them's data are populated???
    thanks in advance!

    solved.

  • Is there really no one who can help me with my question postet 3 days ago!?

    I have a problem with blurry images after publishing -Am I really the only one who thinks this is a big problem -I tried to get some help 3 days ago? Is there other forums that can help me on this topic?
    It looks fine in iweb, but not in the browser after publishing... I'ts only with small logo images with hard graphichs in jpeg, its not my compression, it looks fine before publishing...

    dear wyodor, I thought that I explained my problem all right in my post? well,
    when I put a logo in the corner of my site -in my case a jpg file with some text, it looks good in iweb, but after publishing its not possible to read the small text because of the way iweb compress photos - my question is -can I do anything to keep the jpeg-compression i made i photoshop? Is there no way in iweb to control the compression? Its really frustrating -and the only really problem I have with iweb
    se how my logo looks im my site:
    http://web.mac.com/pierrienevoldsen/24x36.dk/om_24x36.dk.html
    I have the same logo twice now just to check different advises, but still its impossible to read the small lettes -but not in iweb

  • Looking for some one who can help me in SUN IDM

    Hi Friends,
    I am looking for some one who can help me to learn sun IDM. Off couse I will pay for your time.
    I can be reached at [email protected]
    Please let me know if you have some time
    Thx

    Hi Zebra,
    I really appreciate your reply. I would like to discuss out of this forum so that no one here annoyed with our newbie questions. Please send me email as I listed earlier to discuss best ways. I send email to Andy to join us.

  • Need advise, I have purchased compressor 4.1 to compress my movie file, particularly MKV files. Problem is, that the software freezes when trying to import the 10GB MKV. Any one that can help?

    Need advise, I have purchased compressor 4.1 to compress my movie file, particularly MKV files. Problem is, that the software freezes when trying to import the 10GB MKV. Any one that can help?

    Afraid Compressor won't work with MKV. If you have access to a system running an earlier version than Mavericks, and with Perian installed you can use MPEG Streamclip or Quick Time Pro to convert to a mov.
    Russ

  • HT3574 is there any application that can help my iphone 3GS with personal hotspot or tethering internet?

    is there any application that can help my iphone 3GS with personal hotspot or tethering internet?

    You don't need anything, as such is built directly into the iOS. Your carrier, however, needs to support such.

  • I need to download ferefox 9.0 but I cannot find it anywhere. Who can help me with this?

    I need to download ferefox 9.0 but I cannot find it anywhere. Who can help me with this?

    Please note that running out of date versions of Firefox is not recommended, as you will open yourself up to known security issues, alongside bugs and other issues. Is there a specific problem you are having with Firefox that I can help you with?
    You can download Firefox 9 at [http://ftp://ftp.mozilla.org/pub/firefox/releases/9.0.1/win32/en-US/ ftp://ftp.mozilla.org/pub/firefox/releases/9.0.1/win32/en-US/]

Maybe you are looking for

  • Detect remote desktop connection

    Hey, I want to detect if the current user-session is a remote or local session. I have only LabVIEW 2012 at hand, so I think I need it to switch between absolute and relative mouse scrolling detection dependent on the session type. My approach is to

  • How to Replace Null Value as 0 in an OBIEE11g Pivot Table? it's working 10g

    Hi, How to Replace Null Value as 0 in an OBIEE11g Pivot Table? it's working in obiee10g version. We have tried below methods 1) criteria tab and edit the 'column properties' associated with your fact measure. Choose the 'Data Format' tab, tick to ove

  • Rendering Problems in Dreamweaver CS4

    I am having a problem with putting a heading 1 inside of a <div> container whenever I apply the heading to the background of the heading 1 it does not keep the white background it goes to the cobalt colored background in the browser and there does no

  • Syncing problems with apple tv first generation

    Ok I got an apple tv the other day and I am having a hard time syncing anything to it. So I have the first generation apple tv. Its has software 3.0.2 and says it is up to date. I have updated my my itunes to 10.6.3 (25). I am not very computer smart

  • Yeti Pro as stereo mic for guitar and voice

    This mic, which adds xlr phantom power user to the previous USB only, has two pods which can be switched to record stereo.  My question is, is this practical when I am playing acoutic guitar and singing?  My voice is folk-operatic, meaning heavy voic