Why this program doesnt work... what it supposed to do

import java.io.*;
public class try1 {
     public static void main(String[]args)throws Exception
          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
          double int1=1;
          double int2=1;
          double int3=1;
          double x=0;
          System.out.println("Euclids Instruction");
          System.out.println(" ");
          System.out.println("Enter 1st:");
          int1=Integer.parseInt(br.readLine());
          System.out.println("Enter 2nd:");
          int2=Integer.parseInt(br.readLine());
          int3 = int1 - int2;
          System.out.print("Series:");
          System.out.print(int3);
          do
               if (int2>int3)
                    int1=int2;
                    int2=int3;
               int3 = int1 - int2;
               x=int3;
               System.out.print(" " + int3);
               else if(int2<int3)
                    int1=int3;
               int3 = int1 - int2;
               x=int3;
               System.out.println(" " + int3);
          while (x<0);
          System.out.println("GFC" + " " + int3);
IT SHOULD BE LIKE THIS
sample is
first input is 100
sec input is 70
series 30 40 10
GFC should be 10
but out put is 30 40
GFC 40
it doesnt follow the while int3==0
please help

import java.io.*;
public class try1 {
public static void main(String[]args)throws Exception
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
double int1=1;
double int2=1;
double int3=1;
double x=0;
System.out.println("Euclids Instruction");
System.out.println(" ");
System.out.println("Enter 1st:");
int1=Integer.parseInt(br.readLine());
System.out.println("Enter 2nd:");
int2=Integer.parseInt(br.readLine());
int3 = int1 - int2;
System.out.print("Series:");
System.out.print(int3);
do
if (int2>int3)
int1=int2;
int2=int3;
int3 = int1 - int2;
x=int3;
System.out.print(" " + int3);
else if(int2<int3)
int1=int3;
int3 = int1 - int2;
x=int3;
System.out.println(" " + int3);
while (x<0);
System.out.println("GFC" + " " + int3);
FIRST YOU HAVE TO ENTER 2 INPUTS
THE FIRST INPUT("INT1") IS SUBTRACTED FROM THE SECOND INPUT("INT2") THE OUTPUT WILL BE THE THIRD VARIABLE WHICH IS "INT3"
THE SYSTEM WILL THEN CHOOSE FROM INT2 OR INT 3 IF WHO'S GREATER OR LARGER
IF THE SYSTEM DETECTS THAT INT2 IS LARGER THAN INT3 THEN INT1=INT2 AND INT2=INT3
ELSE IF THE INT3 IS GREATER THEN INT3 WILL BE THEN INT1=INT3 AND INT2 WILL REMAIN THE SAME
UNTIL IT REACH THE CONDITION INT3==0
SAMPLE OUTPUT SHOULD BE
<INPUT 1ST>10
<INPUT 2ND>2
OUTPUT SHOULD BE IN
SERIES LIKE 8 6 2
GFC IS 2
BUT WHATS HAPPENING IS IT PRINTS 8 AND 6 .. AND THE GFC IS 6 ...
ERRR DID I EXPLAIN IT RIGHT?

Similar Messages

  • Why this path doesnt work when there is "!DOCTYPE" element?

    Hi, I need to extract contents from an xml file, which looks like
    <hr />
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE article PUBLIC "-//ES//DTD journal article DTD version 5.0.1//EN//XML" "xyz501.dtd" > <!-- LINE 1 -->
    <article docsubtype="fla">
    <item-info>
    <jid>YANBE</jid>
    <aid>12941</aid>
    </item-info>
    </article>
    <hr />
    And I have tested with this path "//article/item-info/jid/text()", but it doesnt give me anything. But I noticed that when I remove line 1, it does extract the content "YANBE"...
    why the path doesnt work when there is that DOCYTYPE element? How should I get around with this please?
    Many thanks!

    The extract of XML you gave is not valid (Line 1: <hr/>) but besides that ... I think your problem is in the DTD.
    Somewhere in the DTD it probably 'sneakily' defines a default attribute which in reality is a default-namespace for one of the elements. This means that in your XPath handling, you will have to map a prefix to a namespace-uri (NamespaceContext [1]) and use this newly defined prefix in your XPath expression.
    //tst:article/tst:item-info/tst:jid/text()[1] http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/namespace/NamespaceContext.html

  • Anyone know why this program aint working

    i pretty much copied most of the code from an example program but this one doesnt seem to be working
    the error says i need another } but keeps saying the same thing when i add one
    import java.io.*;
    //this is a cprogram i have created so the users data entered into my main program can be read in a text file
    class cdetailreader
         public static void main (String args[])
              int input;
              try
                   // I have created a filereader to read the contents of the text file i created to hold customer data
                   // In my main program i named the text file to store customer details cdetails.txt
                   FileReader readcdetails = new fileReader("cdetails.txt");
                   input = reader.read();
                   While (input >=0)
                        System.out.print ((char) input);
                        input = reader.read();
              catch(Exception e){
              System.out.println("File does not exist"+e);
    }

    nice one mate it is actually a error in the program
    example but should have guessed. thanks for helpI suggest you ditch that source and find another one that doesn't suck.

  • Why this program don't work without the "stop"?

    can you tell me why this program don't work without "stop"?and why the "stop" of my program can not work?
    Attachments:
    N(%}QA2R@SOLAF_12~0SQ)A.jpg ‏67 KB

    Crossrulz, sometimes you can snip the URL of the image:
    http://forums.ni.com/ni/attachments/ni/170/823066/1/
    The stop button is checked once in every iteration of the while loop, which includes waiting for the for loop to complete its 9 iteration.
    The for loop takes 9 seconds to complete because of the time delay, therefore clicking the stop button can take upto 18 seconds, depending on whether the button has been read yet.
    Turn on the highlight execution )light bulb icon) to see what is happening in your code
    - Cheers, Ed

  • I forgot my ipod password and i didnt use it for along time so it wont even connect to itunes plus it fell in the toilet so my home button and volume button doesnt work what do i do?

    I forgot my ipod password and i didnt use it for along time so it wont even connect to itunes plus it fell in the toilet so my home button and volume button doesnt work what do i do?

    Place the iOS device in recovery mode using this program
    RecBoot: Easy Way to Put iPhone into Recovery Mode
    http://jaxov.com/2010/05/recboot-iphone-recovery-mode/and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                          
    If recovery mode does not work try DFU mode.                         
    Enter DFU mode without home button or Power Button | technoNix
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • My iphone 4 is stuck on the reboot logo, ive ried holding both home and power to shut it off snd then keep holding home to let you plug it into itunes but it doesnt work. what do i do?

    my iphone 4 is stuck on the reboot logo, ive ried holding both home and power to shut it off snd then keep holding home to let you plug it into itunes but it doesnt work. what do i do?

    Did you try rebooting the iPad? You will need to have some battery power for this.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    This may be helpful
    iPhone, iPad or iPod touch: Not responding or does not turn on
    Frozen or unresponsive iPad - Apple
    iPad: Unable to update or restore

  • I need help getting this program to work.

    K. I don't pay much attention in my AP Comp Science Class.. but my teacher said if i can get this program to work i get an a for the semester... The program is Metrowerks Codewarrior IDE.. we are running it on windows 98 i think. She said she can't get it to compile.. so i guess it just needs to be able to input simple java programs (i.e. loops, just the regular crap) and compile them and run them...i have no clue what is wrong with it.. it could just need a patch...or we may just be going about it the wrong way...any help would be SUPER appreciated...

    K. I don't pay much attention in my AP Comp Science
    Class.. but my teacher said if i can get this programYou better did.
    to work i get an a for the semester... The program is
    Metrowerks Codewarrior IDE.. we are running it on
    windows 98 i think. She said she can't get it toAtleast be sure of the OS.
    compile.. so i guess it just needs to be able to
    input simple java programs (i.e. loops, just the
    regular crap) and compile them and run them...i have
    no clue what is wrong with it.. it could just need aEven we don't.
    patch...or we may just be going about it the wrong
    way...any help would be SUPER appreciated...Nothing in your thread really speaks of the problem. And since you mentioned homework, there's hardly anyone to be interested in that.
    Regards
    ***Annie***

  • Confused as to why this doesn't work...

    I wrote this code correctly, but it doesn't seem to work. I'm not sure if I'm leaving something out or not using something correctly. If anyone can tell me why this doesn't work, it would be greatly appreciated!
    P.S. in the actionPerformed method, I want to put the window to close once someone clicks an "ok" button. How is this done? I've tried using setDefaultCloseOperation(3), but it doesn't seem to work.
    peace,
    Mark
    //?2002 Copyright. MJA Technologies.  All Rights Reserved.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class About extends JFrame implements ActionListener
        JTextArea textarea;
        JPanel panel1;
        JButton okbutton;
        String output;
        public About()
            super("Pages");
            Container container = getContentPane();
            textarea = new JTextArea();
            textarea.setText("Pages 1.0 beta 0\n?2002 MJA Technologies.\nAll Rights Reserved.");
            container.add(textarea);
            setDefaultCloseOperation( 3);
            setVisible(true);
            setSize(400, 300);
        public void actionPerformed(ActionEvent event)
            if(event.getSource() == okbutton)

    Oh see, you said this:
    "P.S. in the actionPerformed method, I want to put the window to close once someone clicks an "ok" button. How is this done? I've tried using setDefaultCloseOperation(3), but it doesn't seem to work."
    so I said this:
    "setVisible(false)"
    NOOOOOOOOOOOW you say the TextArea doesn't show up...that's a whole other problem.
    Jeeeeeeeeeeeeeeeez.
    So what layout manager are you using in the container? (hint hint)

  • My ipod touch says its disabled, and i tried restoring it but it doesnt work what can i do?

    my ipod touch says its disabled, and i tried restoring it but it doesnt work what can i do?

    See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...
    Be sure to Follow ALL the Steps...

  • I need a program for camera.The androide has a program IP Cam View basic that has the fohu HA 425 and I get the cameras.I downlouded the IP camera viewer in the Aple but this program doesnt have the fuho HA 425. Which apple program is compatible?

    I need a program for camera.The androide has a program IP Cam View basic that has the fohu HA 425 and I get the cameras.I downlouded the IP camera viewer in the Aple but this program doesnt have the fuho HA 425. Which apple program is compatible?

    Hi,
    As far as I know, Sony Ericsson Z520, like a lot of the other cell phones, doesn�t support bluetooth serial communication.
    See:
    http://developer.sonyericsson.com/entry.jspa?externalID=138&categoryID=5
    BUT(!) You should double check this information.
    If you ask me, we have done similar project.
    We are working on hobby project � our robot use J2ME cell phone as on-board brain.
    And there is connection between this small robot and Linux-based PC.
    Communication was done via BlueTooth (in reality we use Linux implementation of BlueTooth stack and obexftp).
    BUT (!) We use Siemens S75 for this communication.
    I�m afraid that Siemens is the only manufacture, which implemented serial communication over bluetooth, embedded camera and non-usb socket.
    Also there are some Motorola phones, which implement serial communication over bluetooth.
    But � note that all Motorola phones use USB sockets and it will not be easy for you to make connection between such a phone and the robot.
    If you need just connection between cell phone and PC, then may be USB is OK too.
    Our robot project: www.RoboHobby.com

  • When i try to sync my old ipod touch. it says theres a error. so i update it and reset it and stuff but it still doesnt work. what should i do?

    When i try to sync my old ipod touch. it says theres a error. so i update it and reset it and stuff but it still doesnt work. what should i do?

    Before you restore the iPod from the backup that Dave had you make yu have to transfer stuff from the iPod to the computer since the backup does not contain the apps themselfes, music, synced phots and some other stuff.  To see what a backup contains see:
    http://support.apple.com/kb/HT4946
    To transfer iTunes purchases:
    iTunes Store: Transferring purchases from your iPhone, iPad, or iPod to a computer
    - For other stuff you need a third-party program like one of those discussed here:
    Copy music from Ipod to new computer...: Apple Support CommunitiesA lot of thos are paid, especiall for more than a limited number of items.  It is harder to find one that does synced photos.

  • My computer keeps saying that itunes is not working so i updated my windows and reinstalled itunes but it still doesnt work what do i do?

    my computer keeps saying that itunes is not working so i updated my windows and reinstalled itunes but it still doesnt work what do i do?

    This link will give service options for your Country ,select from drop down menu
    http://support.apple.com/kb/index?page=servicefaq&geo=United_Kingdom&product=iph one
    To troubleshhoot restore see document below
    http://support.apple.com/kb/HT1808

  • TS1424 how to fix error 21 my iphone doesnt work what should i do????

    how to fix error 21 my iphone doesnt work what should i do????

    Hello,
    I found this article that should help you out:
    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    http://support.apple.com/kb/TS3694
    It says the following about Error 21:
    These errors typically occur when security software interferes with the restore and update process. Follow Troubleshooting security software issues to resolve this issue. In rare cases, these errors may be a hardware issue. If the errors persist on another computer, the device may need service.
    Also, check your hosts file to verify that it's not blocking iTunes from communicating with the update server. See iTunes: Advanced iTunes Store troubleshooting—follow steps under the heading Blocked by configuration (Mac OS X / Windows) > Rebuild network information > Mac OS X > The hosts file may also be blocking the iTunes Store. If you have software used to perform unauthorized modifications to the iOS device, uninstall this software prior to editing the hosts file to prevent that software from automatically modifying the hosts file again on restart.
    Hope that helps,
    David

  • I have purchased two audiobooks from iTunes. They play perfectly for about 13 minutes and then abruptly stop. I have purchased other audiobooks and have not had a problem. Please, any ideas on why this is happening and what can I do to fix it.  Thanks!

    I have purchased two audiobooks from iTunes. They play perfectly for about 13 minutes and then abruptly stop. I have purchased other audiobooks and have not had a problem. Please, any ideas on why this is happening and what can I do to fix it.  Thanks!

    As long as you use your computer like King Penguin stated for Report a Problem, you should be fine. If you can't get to your computer, are not using your computer, or your computer is not longer in the mix since you have been using your iPad, email iTunes support about the problem.
    http://www.apple.com/emea/support/itunes/contact.html

  • My MacBook Pro doesn't start; in safe mode shift CMD V the message "disk0s2: media is not present" is written on the screen repeatedly but the MacBook doesn't start.  Do you have any ideas of why this should be or what I should do to resolve this?

    My MacBook Pro doesn't start; in safe mode <shift CMD V> the message "disk0s2: media is not present" is written on the screen repeatedly but the MacBook doesn't start.  Do you have any ideas of why this should be or what I should do to resolve this?  Thanks  Eamonn

    Thanks for these suggestions: I have tried safe mode re-starts (both "verbose" and simple "shift" + power) to no avail.  I get the error message "disk0s2: media is not present".  Following this I inserted the installation disc and from there ran disc utility.  The "Verify Disk" indicated an error " invalid sibling link" which it could not repair.
    I also tried to completely re-format/erase the disk, but again got an error message "disk object invalid or unable to serialize".
    Any ideas of what could be causing this or the best solution?  I fear I am fast running out of options.

Maybe you are looking for