I don't understand why my loop isn't working. Can someone help, please?

public class PolarMain {
     public static void main(String[] args) {
          Polar p1 = new Polar(45, 50, 10, 10);
          System.out.println(" X1 " +p1.x1 +" New X1 " + p1.newX(45, 50 , 10 , 10)
           + " Y1 " +p1.y1 +" New Y1 " + p1.newY(45, 50 , 10 , 10));
     Polar p2 = new p2();
     for (i = 1; i < 10; i++)
     p2 = new (47, 49, 7, 7)
     System.out.println(" X1 " +p1.x1 +" New X1 " + p1.newX(47, 49 , 7 , 7)
           + " Y1 " +p1.y1 +" New Y1 " + p1.newY(47, 49, 7 , 7));
     I get the error message "illegal start of type" on line 14 and "identifier expected" on line 18.
TIA.
     }

see comments:
public class PolarMain {
    public static void main(String[] args) {
        // this code below is all within the main method... no problem
        Polar p1 = new Polar(45, 50, 10, 10);
        System.out.println(" X1 " +p1.x1 +" New X1 " + p1.newX(45, 50 , 10 , 10)
         + " Y1 " +p1.y1 +" New Y1 " + p1.newY(45, 50 , 10 , 10));
    // all of the code below here is within NO method.  Big problem.
    Polar p2 = new p2(); // what is new p2()?  Do you have a class p2 or an object p2.
    for (i = 1; i < 10; i++)
    p2 = new (47, 49, 7, 7)   // this is way out in left field.  new .... what?  no class name
    System.out.println(" X1 " +p1.x1 +" New X1 " + p1.newX(47, 49 , 7 , 7)
         + " Y1 " +p1.y1 +" New Y1 " + p1.newY(47, 49, 7 , 7));
    }This all suggests to me that in order for you to progress, in order for you to be at a level where we can advise you, you must study and understand the fundamentals of java first. We could re-write this code for you to get it to work, but for what purpose? You need to go over the introductory tutorials asap.
Good luck!

Similar Messages

  • I don't understand why this simple program will not print.  Help please!!!

    This program runs with no errors, it just doesn't print anything. Anyone have a clue as to why it doesn't print anything?
    Here is my code:
    import javax.swing.JOptionPane;
    public class Converter {
    public static void main(String[] args) {
    int a,b,c;
    int inputNum=Integer.parseInt(JOptionPane.showInputDialog(null," Enter a length in yards: "));
    String measurement = JOptionPane.showInputDialog(null,"Enter the unit of conversion (inches, feet, or centiyards): ");
    if (measurement == "inches"){
    a = inputNum*36;
    System.out.println(a + "inches");
    else if (measurement == "feet"){
    b = inputNum*3;
    System.out.println(b + "feet");
    else if (measurement == "centiyards"){
    c = inputNum*100;
    System.out.println(c + "centiyards");
    }

    Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same character sequence), use equals(), e.g. if (str1.equals(str2))...
    Example:String s1 = "foo";
    String s2 = new String("foo");
    System.out.println("s1 == s2: " + (s1 == s2)); // false
    System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out the Java FAQ
    ~

  • I don't know why my code isn't working, Can you see what is wrong?

    I'm putting together a program that reads input from a text file and then decides what type of input it is (male or female) and then calculates the final sum for both.
    m=male and f=female. The numbers after the letter are GPAs. Here is the input file:
    m 2.4
    f 3.2
    m 3.7
    m 4.0
    f 2.9
    f 1.8
    f 3.8
    m 1.7
    m 3.4
    f 2.6
    m 2.8
    m 1.7
    f 3.7
    m 3.9
    f 4.0
    f 3.6
    m 2.3
    f 2.9
    m 3.0
    m 2.7now here is my code:
    import java.io.*;
    import java.util.*;
    public class gradecalc {
         * @param args the command line arguments
        public static void main(String[] args)
                                throws FileNotFoundException{
            // TODO code application logic here
    double sumMale=0;
    int numMale=0;
    double sumFemale=0;
    int numFemale=0;
    char gender;
    double gpa;
         Scanner inFile= new Scanner(new FileReader("gpa.txt"));
            PrintWriter outFile= new PrintWriter("gpaResult.txt");
    while (inFile.hasNext())
        gender= inFile.next().charAt(0);
        gpa= inFile.nextDouble();
        switch (gender)
            case 'M':
            case 'm':
                sumMale= sumMale + gpa;
                numMale++;
                break;
            case 'F':
            case 'f':
                sumFemale= sumFemale + gpa;
                numFemale++;
                break;
            default:
                System.out.println("Invalid gender code: "+gender);
    outFile.print("Sum of male students GPAs: " + sumMale);
    outFile.print("Sum of female students GPAs: " + sumFemale);
    outFile.close();
    }and this is the error message I get when I build and then try to run the program:
    init:
    deps-jar:
    compile:
    run:
    Exception in thread "main" java.util.NoSuchElementException
            at java.util.Scanner.throwFor(Scanner.java:838)
            at java.util.Scanner.next(Scanner.java:1461)
            at java.util.Scanner.nextDouble(Scanner.java:2387)
            at gradecalc.main(gradecalc.java:32)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 0 seconds)I feel like I have the code right, yet it doesn't output anything to my file and gives me the above exception. What's the problem here??

    I actually figured it out. I think some of you programmers out there would be proud of me if you saw this completed code. This forum has really helped me out, but I still make some stupid mistakes. Like the one I realized I made on this program seconds after I made this pose. I realized that I had an unknown character at the end of my input document, which you can't see in my post because I must have not copied and pasted that part. I would delete this post, but don't know how.

  • My iPod 4tb gen's camera isn't working.Can someone help me?

    My camera isn't workuiing and I've tried yo.Please help

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                                                                
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
      Apple Retail Store - Genius Bar              

  • HT5457 I got the 1st iPad but it needs iOS on it I don't know how to go about getting it can someone help me

    I got the 1st iPad but it needs iOS on it I don't know how to go about getting it can someone help me

    If you have an iPad 1, the max iOS is 5.1.1. For newer iPads, the current iOS is 6.0.1. The Settings>General>Software Update only appears if you have iOS 5.0 or higher currently installed.
    iOS 5: Updating your device to iOS 5 or Later
    http://support.apple.com/kb/HT4972
    If you are currently running an iOS lower than 5.0, connect the iPad to the computer, open iTunes. Then select the iPad under the Devices heading on the left, click on the Summary tab and then click on Check for Update.
    Tip - If connected to your computer, you may need to disable your firewall and anitvirus software temporarily.  Then download and install the iOS update. Be sure and backup your iPad before the iOS update.
     Cheers, Tom

  • I have downloaded iCloud control panel but when I sign in with my iTunes username and password it say they are valid but I don't have an iCloud account and Iam lost can you help please.                                                        John

    I have downloaded iCloud control panel but when I sign in with my iTunes username and password it say they are valid but I don’t have an iCloud account and Iam lost can you help please.
    John

    You are getting this message because you are trying to create an iCloud account on a PC.  You can only create iCloud account on an iOS device (iPhone, iPad or iPod Touch) running iOS 5 or higher, or on a Mac running OS X Lion (10.7.5) or higher.  After creating your account on one of these devices you will then be able to sign into the account using this ID on your PC.

  • Im trying to get some purchased songs to sync onto my ipad, but when i try it says they could not be synced as i need to authorise my computer which has been done already but its still not syncing them can someone help please?

    Im trying to get some purchased songs to sync onto my ipad, but when i try it says they could not be synced as i need to authorise my computer which has been done already but its still not syncing them can someone help please?

    Hello there, Gemss.
    The following Knowledge Base article offers up some great recommendations for the issue you're describing:
    iTunes repeatedly prompts to authorize computer to play iTunes Store purchases
    http://support.apple.com/kb/TS1389
    Although all of the scenarios may be applicable, many folks find that the following section helps resolve their issue most often:
         Authorize using the correct account name
    The items you're trying to play might have been purchased using a different iTunes Store account. To determine which account was used to purchase an item, follow these steps:
    Select a purchased song in your library and choose File > Get Info.
    Click the Summary tab. Note the Account Name that appears in the list. This is the account name (Apple ID) you'll need to use when authorizing your computer to play this purchase.
    Note: The account name that appears is the one you used when purchasing the item and does not change if the account name (Apple ID) changes.
    If you've authorized the Apple ID that is shown in the Summary tab, you can check the purchase history for that Apple ID from Store > View My Account. If your purchase history does not reflect the purchase of the items in your iTunes library, consider any other Apple ID you may have created, and authorize the computer for your additional Apple ID.
    If you forgot the password to one of your accounts, you can recover it using Apple's password-recovery website.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • If someone phones my mobile number, they are prompted to leave a 10-second message which them comes to me as a text.  I want real voicemail with real voices but I don't know how to set it up on my iPhone4S.  Can someone help please?

    If someone phones my mobile number, they are prompted to leave a 10-second message which them comes to me as a text.  I want real voicemail with real voices but I don't know how to set it up on my iPhone4S.  Can someone help please?

    Ask your wireless provider.  None of what you describe has to do with the phone itself.

  • The address bar disappeared from all webpages and I don't know how to get it back. Can someone help me?

    The address bar disappeared from all web pages and I can't type in a webpage.  I don't know how to get it back.  Can someone PLEASE help me get it back?  Thanks!!!

    Hi Jordyn. I'm assuming you're using Safari. Open it. On the top bar click on View > Customize Toolbar. You should see the address bar there and simply drag it where you want to place it in Safari. Hope this helps.

  • HT1386 My new iPad isn't showing as a device in iTunes. Can someone help please ?

    Hi,
    My new iPad isn't showing as a device in ITunes. Can someone tell me what I'm doing wrong please ?
    Thanks

    Have you got the latest version of iTunes on your computer ? There is some troubleshooting for a device not showing in iTunes on this page : http://support.apple.com/kb/TS1538

  • I don't understand why my code is not working please help!

    import(flash.events.MouseEvent);{
    stop();
    button1.addEventListener(MouseEvent.CLICK,showpic1);
    button1.addEventListener(MouseEvent.CLICK,showpic2);
    button1.addEventListener(MouseEvent.CLICK,showpic3);
    button1.addEventListener(MouseEvent.CLICK,showpic4);
    function showpic1(Event:MouseEvent);{
              gotoAndstop("pic1");
    function showpic2(Event:MouseEvent);{
              gotoAndstop("pic2");
    function showpic3(Event:MouseEvent);{
              gotoAndstop("pic3");
    function showpic4(Event:MouseEvent);{
              gotoAndstop("pic4");

    And another thing. Event (with capital E) is a particular datatype in AS3. You should avoid using reserved words. The handlers should look like this:
    function showpic1(event:MouseEvent);
              gotoAndStop("pic1");

  • HT201263 I cannot get my iphone to restore after the latest update, it seems this is the "recovery loop" my phone is "dead" can someone help please

    My Iphone 4s never restarted after installing the latest upgrade. I understand this is called the recovery loop. It will not restart after going through the recovery process in itunes. What do I do as the phone is completely dead to all intents and purposes. What on earth do I do???

    Try and put it DFU mode and do a manual install, as outlined in the link below.
    Basic troubleshooting steps  
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101
     In Memory of Steve Jobs 

  • At work 1000's of Ai files are corrupted. Not sure why they wont read in. Can someone help?

    I work at a coin design maker and our old files seem to be corrupted. I could use some help figuring this out.
    Patrick

    If PS does not recognize the file, it seems to confirm the file is corrupted.
    Is the file the expected size on disk? Are you opening from a server? Do you have a recent backup to pull from to try to determine when the corruption started?

  • Can someone help please. I recently boughYou have no bookmarks.t a IPad Air, when I go to Utube on Google I don't get sound, when I go to the same site on Safari I get sound? Thank you. Mark

    I recently bought a iPad air, when I use Google and go to Utube I do not get sound, when I go to the same site using Safari I do get sound? Can someone explain please, thank you. Mark

    Hello there, Mark.
    The following Knowledge Base article offers up some great recommendations for troubleshooting issues with apps downloaded from the App Store:
    iOS: Troubleshooting apps purchased from the App Store
    http://support.apple.com/kb/ts1702
    In your case you may also want to close all apps that are running during the "Restart the App" step.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • My usb 5 button mouse isn't working properly need help please

    I tried to change my xorg  to use usb but I couldn't boot if I changed anything to do with my mouse my mouse used to work and light up like it was supposed to.  anyways this is the errors from my error log
    May 30 18:20:16 Shadowfire usb 1-1: device not accepting address 2, error -71
    May 30 18:20:16 Shadowfire hub 1-0:1.0: unable to enumerate USB device on port 1
    May 30 18:20:16 Shadowfire hub 4-0:1.0: unable to enumerate USB device on port 1
    May 30 18:20:16 Shadowfire hub 4-0:1.0: unable to enumerate USB device on port 3
    May 30 18:20:16 Shadowfire hub 4-0:1.0: unable to enumerate USB device on port 4
    May 30 18:52:17 Shadowfire hub 2-0:1.0: unable to enumerate USB device on port 1
    May 30 18:52:17 Shadowfire hub 7-0:1.0: unable to enumerate USB device on port 1
    May 30 18:52:17 Shadowfire hub 7-0:1.0: unable to enumerate USB device on port 3
    May 30 18:52:17 Shadowfire hub 7-0:1.0: unable to enumerate USB device on port 4
    May 30 19:14:59 Shadowfire hub 2-0:1.0: unable to enumerate USB device on port 1
    May 30 19:14:59 Shadowfire hub 2-0:1.0: unable to enumerate USB device on port 3
    May 30 19:14:59 Shadowfire hub 2-0:1.0: unable to enumerate USB device on port 4
    May 30 19:21:58 Shadowfire hub 2-0:1.0: unable to enumerate USB device on port 1
    May 30 19:21:58 Shadowfire hub 2-0:1.0: unable to enumerate USB device on port 3
    May 30 19:21:58 Shadowfire hub 2-0:1.0: unable to enumerate USB device on port 4
    and this my xorg for some reason it has a number of  different mouse settings
    Section "ServerLayout"
    Identifier "Xorg Configured"
    Screen 0 "Screen0" 0 0
    InputDevice "Keyboard0" "CoreKeyboard"
    InputDevice "PS/2 Mouse" "CorePointer"
    # Serial Mouse not detected
    # USB Mouse not detected
    EndSection
    Section "ServerFlags"
    Option "AllowMouseOpenFail" "true"
    EndSection
    Section "Files"
    RgbPath "/usr/share/X11/rgb"
    ModulePath "/usr/lib/xorg/modules"
    FontPath "/usr/share/fonts/misc:unscaled"
    FontPath "/usr/share/fonts/misc"
    FontPath "/usr/share/fonts/75dpi:unscaled"
    FontPath "/usr/share/fonts/75dpi"
    FontPath "/usr/share/fonts/100dpi:unscaled"
    FontPath "/usr/share/fonts/100dpi"
    FontPath "/usr/share/fonts/PEX"
    # Additional fonts: Locale, Gimp, TTF...
    FontPath "/usr/share/fonts/cyrillic"
    # FontPath "/usr/share/lib/X11/fonts/latin2/75dpi"
    # FontPath "/usr/share/lib/X11/fonts/latin2/100dpi"
    # True type and type1 fonts are also handled via xftlib, see /etc/X11/XftConfig!
    FontPath "/usr/share/fonts/Type1"
    FontPath "/usr/share/fonts/ttf/western"
    FontPath "/usr/share/fonts/ttf/decoratives"
    FontPath "/usr/share/fonts/truetype"
    FontPath "/usr/share/fonts/truetype/openoffice"
    FontPath "/usr/share/fonts/truetype/ttf-bitstream-vera"
    FontPath "/usr/share/fonts/latex-ttf-fonts"
    FontPath "/usr/share/fonts/defoma/CID"
    FontPath "/usr/share/fonts/defoma/TrueType"
    EndSection
    Section "Module"
    Load "ddc" # ddc probing of monitor
    Load "dbe"
    Load "dri"
    Load "extmod"
    Load "glx"
    Load "bitmap" # bitmap-fonts
    Load "type1"
    Load "freetype"
    Load "record"
    # Load "synaptics"
    EndSection
    Section "InputDevice"
    Identifier "Keyboard0"
    Driver "keyboard"
    Option "CoreKeyboard"
    Option "XkbRules" "xorg"
    Option "XkbModel" "pc105"
    Option "XkbLayout" "us "
    Option "XkbVariant" ""
    EndSection
    Section "InputDevice"
    Identifier "Serial Mouse"
    Driver "mouse"
    Option "Protocol" "Microsoft"
    Option "Device" "/dev/ttyS0"
    Option "Emulate3Buttons" "true"
    Option "Emulate3Timeout" "70"
    Option "SendCoreEvents" "true"
    EndSection
    Section "InputDevice"
    Identifier "PS/2 Mouse"
    Driver "mouse"
    Option "Protocol" "auto"
    Option "ZAxisMapping" "4 5"
    Option "Device" "/dev/psaux"
    Option "Emulate3Buttons" "true"
    Option "Emulate3Timeout" "70"
    Option "SendCoreEvents" "true"
    EndSection
    Section "InputDevice"
    Identifier "USB Mouse"
    Driver "mouse"
    Option "Device" "/dev/input/mice"
    Option "SendCoreEvents" "true"
    Option "Protocol" "IMPS/2"
    Option "ZAxisMapping" "4 5"
    Option "Buttons" "5"
    EndSection
    # Auto-generated by Archie mkxcfg
    Section "Monitor"
    Identifier "aticonfig-Monitor[0]"
    Option "DPMS" "true"
    EndSection
    # Auto-generated by Archie mkxcfg
    Section "Device"
    Identifier "Card0"
    Driver "fglrx"
    VendorName "All"
    BoardName "All"
    # BusID "PCI:1:0:1"
    EndSection
    Section "Screen"
    Identifier "Screen0"
    Device "Card0"
    Monitor "Monitor0"
    DefaultColorDepth 24
    SubSection "Display"
    Depth 1
    Modes "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 4
    Modes "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 8
    Modes "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 15
    Modes "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 16
    Modes "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 24
    Modes "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 32
    Modes "1024x768" "800x600" "640x480"
    EndSubSection
    EndSection
    Section "DRI"
    Group 0
    Mode 0666
    EndSection
    Section "Extensions"
    Option "Composite" "Enable"
    Option "RENDER" "Enable"
    Option "DAMAGE" "Enable"
    EndSection
    Last edited by Shadowmeph (2008-05-31 16:35:53)

    Sounds like you might have an interaction misapplied to some part of the component. I would look around for a rogue On Click interaction, and also look at what the Pressed states look like of the button.
    Chris

Maybe you are looking for