What im doing wrong in the loop?

Mistyped
Edited by: 794018 on Sep 20, 2010 5:11 AM

>
How I can change this code
to have the output like this
>
Well you need to look at your output and see where the first line of output is wrong.
This is the first line of output
>
3          120
>
If that line is not correct ask yourself where those values came from.
The output is done by this line
System.out.format ("%s\t\t%s\n",i,dist);So the 3 came from 'i' and the 120 came from 'dist'.
Is the 3 correct? If not then 'i' is not correct.
So look at your code one line at a time and try to figure out why the first value of 'i' is not correct.
        for (int i = numberOfhoursTraveled; i < milePerhour; i++) {
           dist = (int) convertDistanceTraveled(milePerhour, numberOfhoursTraveled);What is the value of 'i' the first time through the loop? It is numberOfhoursTraveled which is 3. Is that what you want?

Similar Messages

  • HT1386 i got a used ipod touch and when I connect it - it doesn't show up on my computer. I have an Itunes account and it does not show my device at all. any clue what I', doing wrong? The ipod is on and plugged in

    I am having trouble - when I turn on my ipod touch - the only thing on the screen is a usb cable with an arrow pointing to the itunes logo. I got it from a friend who cleared all of his stuff off of it. I can't get any of the stuff I downloaded on it. maybe it didn't sync with my computer. it doesn't show up when I go to the itunes store on the top bar next to the library tab either. HELP ! lol

    iOS: Device not recognized in iTunes for Windows
    or
    iOS: Device not recognized in iTunes for Mac OS X

  • Itunes document manager pro will not open a document with .cwk extension. It will catch the document then error message states that it cannot open document. Can anyone tell me what Im doing wrong?

    Itunes document manager pro will not open a document with .cwk extension. It will catch the document then error message states that it cannot open document. Can anyone tell me what Im doing wrong?

    Forgive my ignorance but I have never hear of iTunes Document Manager Pro. If you mean Document Manager Pro, i was able to find that. Back to your problem, have you tried opening one of those files in the iOS iWorks apps? Form the quick read that I did about this, .cwk files can be opened by Pages, Numbers or Keynote, depending on what type of document that it is and those files can be read by Document Manager Pro, after properly saving them. I don't see that you can go directly from the .cwk file in Document Manager Pro without converting them first.
    I took a very quick look at the app, so I may be a missing something about its capability.

  • HT4352 appletv - the airplay window on iphone 4gs and ipad gen2 does not show the mirroring slider? any one know what im doing wrong?

    appletv - the airplay window on iphone 4gs and ipad gen2 does not show the mirroring slider? any one know what im doing wrong?

    ccooper52
    check out the tips and video at the bottom of this link and see if any of it helps
    http://www.allabouthomeelectronics.com/apple-tv-airplay.html
    Apple policy requires we mention we might benefit or profit somehow by your visit
    please let us know if this helped

  • I have to guess where the comma is the @ sign is and various signals now tell what am i doing wrong on the apple usb keyboard

    I have to guess where the comma is the @ sign is and various signals now tell what am i doing wrong on the apple usb keyboard

    Hello
    This can be verry usefull
    http://support.apple.com/kb/HT2841?locale=en_US
    How to identify keyboard localizations
    HTH
    Pierre

  • I just purchased a complete series on itunes... Im trying to watch the episodes but its only showing 20 seconds.. can some one help me know what Im doing wrong?

    I just purchased a complete series on itunes... Im trying to watch the episodes but its only showing 20 seconds.. can some one help me know what Im doing wrong?

    Hi bibisandoval,
    Thanks for visiting Apple Support Communities.
    If the movie has completely downloaded, I recommend deleting the movie and downloading it again from your list of purchased movies. See this article for the steps:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/ht2519
    If you are still not able to play the movie, you can report an issue with this purchase using the steps in this article:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
    http://support.apple.com/kb/ht1933
    Regards,
    Jeremy

  • What is wrong with the loop?

    What is wrong with the loop? I am trying to make the loop with start to end dates. What is wrong with those codes that
    I made:
          Calendar startLoop = new GregorianCalendar(2003, Calendar.SEPTEMBER, 01);
          Date datessss = startLoop.getTime();
          Calendar endLoop = new GregorianCalendar(2003, Calendar.SEPTEMBER, 05);
          Date datesssss = endLoop.getTime();
          int result = 0;
          while (endLoop.after(startLoop){
               startLoop.add(Calendar.DATE, 1);
               Date dates5 = startLoop.getTime();
               System.out.println("New Date: " + dates5);
          }Because I got an error those:
    while (endLoop.after(startLoop)Anybody know what is wrong with it?

    In general you'll get better help if you paste in the exact, complete error message.
    In this case it's easy. Count your parentheses.

  • HELP - hi with apple Configurator why does it show with a yellow triangle on the right side of the screen what am i doing wrong for the ipads not syncing or whatever and how do i fix that?

    HELP -- hi with apple Configurator why does it show with a yellow triangle on the right side of the screen what am i doing wrong for the ipads not syncing or whatever and how do i fix that? although i have looked online to try and figure it out and here is the website i found is this the stuff i need to do to fix this? is this site what i need to do to fix this? http://edtechstandish.wordpress.com/what-ive-learned-about-apple-configurator-so -far/  Thanks

    Sorry but I don't know anything about this.  But you might have better luck posting this question over ing the iPad in Business and Education forum here: https://discussions.apple.com/community/ipad/ipad_in_business_and_education?view =discussions.

  • What am I doing wrong with the _ visibility property?

    I have an object that is a movie clip, and I want this object to disappear when you click on him, but also the button that makes the object to appear to make also the object to disappear.Either way, when you click on the object or on the button the second time, the same object to disappear.  I managed to do that, but the first time when you click the button in order to make the object appear it dosen't work, you have to click twice.What am I doing wrong? The object it's a movie clip named frez1, and the button is named fr1. I put this codes in the main timeline:   for the movie clip :           frez1.onPress = function(){                                      _root.frez1.gotoAndStop(2);                                      _root.frez1.gotoAndStop(1);                                           }  for the button:          frez1._visible = false;                                     fr1.onRelease = function(){                                  frez1._visible = !frez1._visible;                              }   The button and the object are on different layers.  Thank you for your help.

    Oh sorry, only now I have seen how it has been displayed. The codes are like this:  for the movie clip:  frez1.onPress = function(){                                     
                                                                                                                                                                _root.frez1.gotoAndStop(2);
                                                                                                                                                                _root.frez1.gotoAndStop(1);   
                                                                                                                                      for the button:   frez1._visible = false;                                   
                                                                                                                                                             fr1.onRelease = function(){                                 
                                                                                                                                                             frez1._visible = !frez1._visible;                             
    Yes the movie clip switching between frames and 1-2 it is turning  him invisible.
    So in order to make him go between this two frames I have to put  the visibity property and not the root ?
    Thank you

  • My I phone doesn't allow me to update my billing information. call somebody tell me what I doing wrong.

    My I phone 4S doesn't allow me to update my billing information. When I entered the new information he keep the old one. After I finished entered the data I press DONE and  I still have the old data.
    Does not accept my new credit card information. Can somebody tell me what I doing wrong and how to fix it.
    Thanks for your assistance.
    papasam 1969

    Did you follow these instructions:
    http://support.apple.com/kb/ht1918

  • What has gone wrong with the equalizer on the latest update, every single one is all distorted

    what has gone wrong with the equalizer on the latest update, every single one is all distorted

    I had a similar-sounding problem with version 11.1.2.31 x64.  Every song I played sounded as if the speakers were being over-driven.  
    This problem was fixed after I installed the new verion: 11.1.2.32 x64.  I am using Windows 7, too.

  • Knows someone absinthe? What can go wrong when the jailbreak? what is VPN?

    knows someone absinthe? What can go wrong when the jailbreak? what is VPN?

    philippwayne wrote:
    What can go wrong when the jailbreak?
    See this Apple doc:
    Unauthorized modification of iOS has been a major source of instability, disruption of services, and other issues

  • What messages does it shows the integration engine(sycn/ asyn)?

    What messages does it shows the integration engine(sycn/ asyn)?

    Status: TO_BE_DELIVERED
    Which means that the message was successfully delivered from Integration Server point of view and it states that the messages is initially handed over to the Messaging System.
    TO_BE_DELIVERED occurs while the message is put into the Messaging System receive queue.
    Solution:
    This is done via the Messaging System receive servlet:
    http://<Host>:<PORT>/MessagingSystem/receive/<CONNECTION>
    /<PROTOCOL>
    Only if this was executed successfully the Messaging System returns HTTP 200 to the Integration Server and the Status TO_BE_DELIVERED moves to DELIVERING
    1. Try logging into Sap GUI with two users: XIAPPLUSER & XIAFUSER
    to see if they are blocked
    2. We can check the messages:
    AdapterFramework
    com.sap.aii.adapterframework.serviceuser.language
    com.sap.aii.adapterframework.serviceuser.name = XIAFUSER
    com.sap.aii.adapterframework.serviceuser.pwd
    ApplicationSystem
    com.sap.aii.applicationsystem.serviceuser.language
    com.sap.aii.applicationsystem.serviceuser.name = XIAPPLUSER
    com.sap.aii.applicationsystem.serviceuser.pwd
    in the exchange profile to make sure the right passwords

  • Hi i have just purchased a mac pro. ive installed word for mac as i wanted to transfer word documents from a windows pc, which are ona usb stick. however i cannot open the usb stick. can anyone tell me what im doing wrong!

    Hi, I've bought a mac pro and installed word for mac, as i wanted to transfer word documents to the new pc. I saved the documents ona usb stick but I cannot open the documents from the stick. What am i doing wrong?
    thanks

    Welcome to the Apple Support Communities
    First of all, check that you are looking for your USB drive in the correct place. To do it, first connect the USB drive. Then, open a Finder window (press the left icon of Dock) and choose your USB drive on the Finder sidebar, under "Devices". Finally, just copy the documents you need to the internal disk.
    If you want to show the USB drive in Desktop, open Finder menu (on the menu bar) > Preferences > General, and tick "External drives"

  • I can't figure out what im doing wrong with my File I/O program lol

    I'm new to the java language and was wondering if anybody could help me with the program i an writing. I don't quite understand file I/O but I've given it my best and I'm stuck. I'm supposed to write a program that will read in a file of student academic credit data and create a list of students on academic warning. The list of students on warning will be written to a file. Each line of the input file will contain the
    student name (a single String with no spaces), the number of semester hours earned (an integer), the total quality points earned (a double). The program should compute the GPA (grade point or quality point average) for each student (the total quality points divided by the number of semester hours) then write the student information to the output file if that student should be put on academic warning. A student will be on warning if he/she has a GPA less than 1.5 for students with fewer than 30 semester hours credit, 1.75 for students with fewer than 60 semester hours credit, and 2.0 for all other students. The instructions are :
    1. Set up a Scanner object scan from the input file and a PrintWriter outFile to the output file inside the try
    clause (see the comments in the program). Note that you’ll have to create the PrintWriter from a FileWriter,
    but you can still do it in a single statement.
    2. Inside the while loop add code to read the input file—get the name, the number of credit hours, and the
    number of quality points. Compute the GPA, determine if the student is on academic warning, and if so
    write the name, credit hours, and GPA (separated by spaces) to the output file.
    3. After the loop close the PrintWriter and Scanner objects in a finally block.
    4. Think about the exceptions that could be thrown by this program:
    • A FileNotFoundException if the input file does not exist
    • A InputMismatchException if it can’t read an int or double when it tries to – this indicates an error in the
    input file format
    • An IOException if something else goes wrong with the input or output stream
    Add a catch for each of these situations, and in each case give as specific a message as you can. The
    program will terminate if any of these exceptions is thrown, but at least you can supply the user with useful
    information.
    5. Test the program. Test data is in the file students.txt. Be sure to test each of the exceptions as well.
    My source code is:
    // Warning.java
    // Reads student data from a text file and writes data to another text file.
    import java.util.*;
    import java.io.*;
    public class Warning
    // Reads student data (name, semester hours, quality points) from a
    // text file, computes the GPA, then writes data to another file
    // if the student is placed on academic warning.
    public static void main (String[] args)
         int creditHrs; // number of semester hours earned
         double qualityPts; // number of quality points earned
         double gpa; // grade point (quality point) average
         Scanner scan=null;
         PrintWriter outFile=null;
         String name, inputName = "students.txt";
         String outputName = "warning.txt";
         try
              // Set up Scanner to input file
              scan=new Scanner(new FileInputStream(inputName));
              // Set up the output file stream
              outFile = new PrintWriter(new FileWriter(outputName));
              // Print a header to the output file
              outFile.println ();
              outFile.println ("Students on Academic Warning");
              outFile.println ();
              // Process the input file, one token at a time
              while (scan.hasNext())
                   // Get the credit hours and quality points and
                   // determine if the student is on warning. If so,
                   // write the student data to the output file.
                   name=scan.next();
                   creditHrs=scan.nextInt();
                   qualityPts=scan.nextDouble();
                   gpa=qualityPts/creditHrs;
                   if ((gpa < 1.5 && creditHrs < 30) || (gpa < 1.75 && creditHrs < 60) || (gpa < 2.0 && creditHrs >= 60))
                        outFile.print(name + " ");
                        outFile.print(creditHrs + " ");
                        outFile.print(qualityPts + " ");
                        outFile.print(gpa);
              //Add a catch for each of the specified exceptions, and in each case
              //give as specific a message as you can
    catch (FileNotFoundException e)
    System.out.println("The file " + inputName + " was not found.");
    catch (IOException e)
    System.out.println("The I/O operation failed and " + outputName + " could not be created.");
    catch (InputMismatchException e)
    System.out.println("The input information was not of the right type.");
              //Close both files in a finally block
    finally
         scan.close();
         outFile.close();
    The txt file is:
    Smith 27 83.7
    Jones 21 28.35
    Walker 96 182.4
    Doe 60 150
    Wood 100 400
    Street 33 57.4
    Taylor 83 190
    Davis 110 198
    Smart 75 292.5
    Bird 84 168
    Summers 52 83.2
    The program will run and then terminate without creating warning.txt. How can I get it to create the warning .txt file? Any help that you could give would be greatly appreciated.

    Alright, here is my code reposted:
    // Warning.java
    // Reads student data from a text file and writes data to another text file.
    import java.util.;
    import java.io.;
    public class Warning
    // // Reads student data (name, semester hours, quality points) from a
    // text file, computes the GPA, then writes data to another file
    // if the student is placed on academic warning.
    public static void main (String[] args)
    int creditHrs; // number of semester hours earned
    double qualityPts; // number of quality points earned
    double gpa; // grade point (quality point) average
    Scanner scan=null;
    PrintWriter outFile=null;
    String name, inputName = "students.txt";
    String outputName = "warning.txt";
    try
    // Set up Scanner to input file
    scan=new Scanner(new FileInputStream(inputName));
    // Set up the output file stream
    outFile = new PrintWriter(new FileWriter(outputName));
    // Print a header to the output file
    outFile.println ();
    outFile.println ("Students on Academic Warning");
    outFile.println ();
    // Process the input file, one token at a time
    while (scan.hasNext())
    // Get the credit hours and quality points and
    // determine if the student is on warning. If so,
    // write the student data to the output file.
    name=scan.next();
    creditHrs=scan.nextInt();
    qualityPts=scan.nextDouble();
    gpa=qualityPts/creditHrs;
    if ((gpa < 1.5 && creditHrs < 30) || (gpa < 1.75 && creditHrs < 60) || (gpa < 2.0 && creditHrs >= 60))
    outFile.print(name " ");
    outFile.print(creditHrs " ");
    outFile.print(qualityPts " ");
    outFile.print(gpa);
    //Add a catch for each of the specified exceptions, and in each case
    //give as specific a message as you can
    catch (FileNotFoundException e)
    System.out.println("The file " inputName " was not found.");
    catch (IOException e)
    System.out.println("The I/O operation failed and " outputName + " could not be created.");
    catch (InputMismatchException e)
    System.out.println("The input information was not of the right type.");

Maybe you are looking for

  • Creative Zen vision M 30 GB MP3 player does not resp

    My Creative Zen vision M 30 GB MP3 player stopped working. It does not turn on, does not charge, does not respond to anything. Is the battery dead or what would be the problem. Please help.

  • Workflow for Goods receipt of an Inbound delivery

    Hello, My requirement is to create a workflow when a GR is done for an Inbound delivery. I was able to get the business objects MKPF,MSEG to use and relevant events. The problem is to publish the event in the system when the GR is done. GR is carried

  • HT201269 Phone call activity on new iPhone, how to make it work??

    Does anybody know how to get PHONE CALL activity on your new iPhone device AFTER you have already backed up your old phone and transferred EVERYTHING onto your new iPhone already ??? I can use the Internet , receive texts... But I cannot make calls !

  • Mac OSX PowerBook G4 to a Tv w/s-video

    I have the above subject lap top - I am would like info - I have a Sony tv w s_video I have a proper cable The tv has a picture from my laptop, a scene only- I do not get the Exact picture from the laptop- Can anyone detail how to get the exact pictu

  • Re: Terrible Customer Service?

    No Windows activation key provided!!!After my hard drive collapsed and i had to replace it (with my own costs) i cant get  windows activation key.I contacted sony support and explained the problem, i gave them model and product number (normaly it sho