New to Java, need assistance

First, I'd like to apologize in case this post is in the wrong place.
Now I'm new to Jcreator and I missed about a month from my computer programming class in school, and am far behind. My assignment right now is this problem p5.12 from Computing Concepts with Java Essentials it says:
"A year with 366 days is called a leap year. A year is a leap year if it is divisible by 4 (for ex.,1980). However, since the introduction of the Gregorian calender on October 15, 1582, a year is not a leap year if it is divisible by 100 (for ex., 1900); however, it is a leap year if it is divisible by 400 (for ex., 2000). Write a program that asks the user for a year and computes whether that year is a leap year., Implement a class *Year* with the method *boolean isLeapYear*
This is the code that I came up with:
import javax.swing.JOptionPane;
public class LeapYear {
     public static void main(String[] args) {
          String input = JOptionPane.showInputDialog("Enter Year");
          double year = Double.parseDouble(input);
          LeapYear newYear = new LeapYear(year);
          System.out.println(newYear.boolean isLeapYear()); //line 11
public class LeapYear {
     private double year;     
     public LeapYear(double year)
               a = year;
          public boolean isLeapYear(){
               if(a % 4 == 0)
                         if(a % 100 != 0) System.out.println("Leap Year");
               else if (a % 400 == 0) System.out.println("Leap Year");
               else System.out.println("Not Leap Year");
The error I am receiving is on the 11th line of the test class. I know if there is something wrong besides that. I'm not asking for someone to fix this for me but I would like if somebody could give me advice on what to do, hints, explain where I went wrong, or know of any good tutorials I could read that could help me with this it would be much appreciated.

Year           Is Leab Year?
1           no      
4            yes
1580            yes
1582           no      
1584            yes      
1600            yes      
1700            no      
1800            no      
1900            no      
1996            yes      
1997           no      
1999            no      
2000            yes      
2100            no      
2200            no      
2300            no      
2400            yes      
2800            yes      
2900            no      
3200            yes      
3300            no      
3600            yes      
3800            no      
4000            yes      
4200            no      
4400            yes      
4700            no      
4800            yes      
5100            no      
5200            yes      
6400            yes      
6500            no      
6800            yes      
6900            no      
7200            yes      
7400            no      
7600            yes      
7800            no           

Similar Messages

  • Very New to Jave, need to do totals/subtotals

    Hi, (I hope this is the right place)
    I'm VERY new to Java (I mainly do wourk with php interfaces for MyAQL databases).
    Up until now, there hasn't been anything I couldn't do with PHP that I needed to...
    My boss recently requested subtotals/totals at various points on an input sheet. The sheet inputs numbers of people, so I'm not worried about rounding (The php already takes care of people trying to input parts of people....) or tax.
    It's a rather large form (~144 lines) and the math is already in place to do the subtotaling (among other things) before entering the information into the database.
    How would I go about writing script that would display sub totals, and recalculate them every time one of the boxes value's is modified?
    Is this something javascript is designed to do? Is there a better language out there for this task?
    I've found sites out there that have canned subtotal/total scripts, but I don't want something pre-made unless it comes with a detailed explaination of what everything does; if I'm going to maintain it, I have to understand it.
    Thanks

    Is this a web form? e.g. a html form with input fields?
    You can add onchange or onblur events to your input fields to detect changes. Then you can use javascript to retrieve the values from the form and do the calculation.
    -S

  • Hi, i'm new to java. need help setting the path in win XP

    hi all,
    i'm new to java technology. i've just downloaded the JDK and ran my first java program (hello world). i love it. java's gr8. i need help. i run win XP and how can i setup the path sothat i can execute my programs from the root dir??? any help in this direction will be greatly appreciated. please email me @ [email protected]
    Best regards
    Mrinal

    Go to Start menu and select Control Panel. In the Control Panel, double click on System. In the System dialogue, choose the Advanced tab. Then click on Environmental Variables. Select Path and Edit. Put ;c:\j2sdk1.4.0\bin at the end of the Path (or c:\j2sdk1.4.0\bin;) at the start of the Path. That's it.

  • New to java(need help on access specifier)

    hi! i am new to java.plzzzzz help me i have to make a project on access specifier's i know all theroy.but
    i am unable to understand how i can define all specifiers practicly.i mean in a program.
    thanks.plzzzzzzzz help me

    the most common project i can think of is a payroll system..
    you can have real implementation of all the access specifiers
    good luck

  • New to java needs advice

    Hi,
    I'm completely new to java and after a few days search found Studio Creator and decided to use it. Happily developing for a week in JSC, I reached the deployment to Tomcat stage.
    Mybe I'm missing something but I find this stage ruining the ease-of-use feeling which I got when I started using JSC.
    Am I right that JSC doesn't have a built-in functionality to deploy to Tomcat whithout my intervention, considering my total unfamiliarity with xml, jsp, mysql, etc.?
    If so do you guys know of another easy-to-use IDE like JSC?
    Any pointers are greatly appreciated.
    Thanks, Abraham

    Hi,
    Try this FAQ on
    How do I deploy web applications developed with Java Studio Creator to the Tomcat Servlet/JSP Container?
    at http://developers.sun.com/prodtech/javatools/jscreator/reference/faqs/technical.jsp
    MJ

  • New to Java need to parse a page on HTTPS server

    Greetings:
    I am writing a "widget" on Macintosh that goes out and gets a simple piece of information from a page within a secure sever (HTTPS).
    The big picture is: I need to send login information which is stored in a JavaScript form to a java application that would go to the https site and login and then go to a page and parse it for a number. This has been done in Perl originally but the Perl requires a specific library added to your system. My java application needs to pass the number back to JavaScript and hence a number will show up in my widget's window. There will be no browser involved... the widgets are JavaScript/XML based.
    I would need a good example of code to do this as I am VERY new. If anyone can help please let me know.

    http://onesearch.sun.com/search/developers/index.jsp?charset=UTF-8&qt=%2Bparse+%2Bhttps&col=javadoc&col=devforums&col=javatecharticles&col=javatutorials&col=devarchive&col=javasc&col=devall

  • New to java, need a applet loop

    Hello, I am trying to create a simple double buffering tile drawing applet based on a two dimensional map array. I have it working fine, however I would like to create a main loop which will keep calling pain() until the escape key is pressed. Can someone please show me how I can do this? Would I need to call repaint() in paint() until escape is pressed? Here is my code.
    import java.awt.Graphics;
    import java.awt.Image;
    import javax.swing.ImageIcon;
    import javax.swing.JApplet;
    public class Tile_engine extends JApplet {
      private final int TILE_MAX = 4;
      private final int TILE_SIZE = 32;
      private final int APPLET_WIDTH = 640;
      private final int APPLET_HEIGHT = 480;
      private final int SKY = 0;
      private final int CLOUD_1 = 1;
      private final int CLOUD_2 = 2;
      private final int RED_BRICKS = 3;
      private final int MAP_ROWS = 15;
      private final int MAP_COLS = 20;
      private Image buffer = null;
      private Graphics bufferg;
      private Image[] tile = new Image[TILE_MAX];
      private final int map[][] =
        {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,0,0,0,0},
         {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
         {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
         {0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
         {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
         {0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0},
         {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
         {0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0},
         {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
         {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
         {0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0},
         {0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0},
         {0,0,0,0,0,0,3,3,0,0,3,0,0,0,0,0,0,0,0,0},
         {3,3,3,3,3,3,3,3,0,0,3,3,3,3,3,3,3,3,3,3},
         {3,3,3,3,3,3,3,3,0,0,3,3,3,3,3,3,3,3,3,3}};
      public void init( ) {
        tile[SKY] = getImage(getDocumentBase(), "sky.png");
        tile[CLOUD_1] = getImage(getDocumentBase(), "cloud_1.png");
        tile[CLOUD_2] = getImage(getDocumentBase(), "cloud_2.png");
        tile[RED_BRICKS] = getImage(getDocumentBase(), "red_bricks.png");
        buffer = createImage(APPLET_WIDTH, APPLET_HEIGHT);
        bufferg = buffer.getGraphics();
      public void paint(Graphics g) {
        if(buffer != null) {
          int tile_id;
          for(int y=0;y<MAP_ROWS;y++) {
            for(int x=0;x<MAP_COLS;x++) {
              tile_id = map[y][x];
              bufferg.drawImage(tile[tile_id], x * TILE_SIZE, y * TILE_SIZE, this);
        g.drawImage(buffer, 0, 0, this);
    }

    Isn't %d an integer? You are passing a double. You need to use the correct formatting type for a double.
    When posting code, please use code tags (see button above posting box). It makes the code much easier to read.

  • New to VLAN - needs assistance

    Hi Guys,
    I just want to ask how to configure the router to connect to VLANs together.
    Please bear with me because I am new to VLANs and Cisco devices and only
    familiar with GUI config not the CLI/IOS.
    SWITCH 1 SG200 50-50 IP:192.168.1.250
    VLAN 10 = PORT 1-20 ACCESS MODE
    SWITCH 2 SG200 50-50 IP:192.168.1.251
    VLAN 10 = PORT 1-20 ACCESS MODE
    They said I would need a router to let these vlans connect to each other so we
    bought the Cisco SA 520 router. So from the router where should I start to connect
    vlan 10 on switch 1 and vlan 10 switch 2?
    I know this is simple to you guys but please show me the initial configuratioin
    and I will try to do the rest of it.
    Many thanks.

    Hi Sunil,
    Our school has plenty of students and staff.
    We are planning to segregate the students machines to staff machines plus the new voip and the servers as well.
    So the school director suggested to use VLAN and use Cisco switches.
    Network Plan:
    Router: Cisco SA 520 router
    We are all connected in 1 Domain and just want to segregate traffic.
    SWITCH 1 SG200 50-50 IP:192.168.1.250
    VLAN 10 = PORT 1-10 ACCESS MODE (This is for the Servers & Printers)
    VLAN 20 = PORT 11-48 ACCESS MODE (for the Staff)
    SWITCH 2 SG200 50-50 IP:192.168.1.251
    VLAN 30 = PORT 1-20 ACCESS MODE (for the IP Phones) VOICE
    VLAN 40 = PORT 21-48 ACCESS MODE (for Students)
    Please bear with me because I am new to cisco devices and work only on GUI.
    So I just need some simple tutorial let say if I want:
    1. VLAN20 (staff) can access VLAN 10 (servers)
    2. VLAN 40 (student) can access VLAN10 (servers)
    3. VLAN 40 (student) can access only let say port 1-3 in VLAN 10
    4. VLAN 20 and VLAN40 should not have an access.
    To help myself as well, I am reading documents about VLANs and trying to understand its configuration
    but since we need to setup this soon, I have asked an assistance here.
    Hope for your assistance.
    Many Thanks.

  • New to SCOM need assistance setting up an Alert / Monitor

    I've recently deployed SCOM 2012R2 to accompany our SCCM deployment and to replace other monitoring software. I'm having difficulty figuring out how to create a monitor that will alert us when a logical drive falls below a specified value of free megabytes.
    I'm having difficulty in finding documentation that will help me do the following:
    We have a 2 node cluster with a 5GB drive (X:) we use as a mounting drive to mount larger disks within as spanned volumes.  We need to have a monitor in place so that we know when these drives are reaching the end of their capacity and we need to bring
    a new one online.  The volumes being mounted here are approximately 2.4TB each.  The monitors we want in place are for if the disk has less than 20GB, 15GB, 10GB, 5GB, 1GB, & 512MB ... so I am looking at 6 alerts total for one disk.
    Once a disk fills up it we stop all write actions to it and start using the new one, so I also need to stop/prevent any space monitoring on disks not currently being written to.
    Any assistance greatly appreciated!
    # When I wrote this script only God and I knew what I was doing. # Now, only God Knows!

    Hi There,
    You can create a basic Simple threshold unit monitor. Target the monitor to "Windows server operating system" with the below configuration as per your screenshot.
    The below setup will do good for Space below 20GB.
    This setup will work if your instance remains same "X:\IMGWH29-33" same all the time in all the machines in which you want this alert.
    So what i have mentioned is for the below X:\ Drive throw a alert if the disk space goes below 20 GB.
    And as the Permfon is collecting data in MB and not in GB hence i have mentioned threshold as 20000 so if the space goes less than 20000 MB (20 gb) throw me an alert.
    Threshold settings Under threshold is critical i.e If it is below 20 Gb throw me an alert, If it is above 20 Gb dont throw me an alert.
    Hope this helps. Also confirm if the instance name  "X:\IMGWH29-33" remains same all the time or not.
    Gautam.75801

  • New to B2B - Need assistance for Starting programing in B2B

    Hi,
    I'm New to B2B. Anybody have links how to start programming in B2B. Prerequisites and how to download them. Currently im able to open b2bconsole.
    I need how to start programming. Any links plz...

    Oracle B2B is not a programming language or a programming based tool. It's a configuration based tool. All the standards have been already implemented as part of the product. You need to just configure it as per your need and you will be good to go.
    Please refer B2B user guide for detailed information about the product and it's offerings -
    http://docs.oracle.com/cd/E23943_01/user.1111/e10229/toc.htm
    Ready-to-use samples are available here -
    http://java.net/projects/oraclesoasuite11g/pages/B2B
    Tutorials are available at OTN B2B Home Page -
    http://www.oracle.com/technetwork/middleware/b2b-integrations/overview/index.html
    B2B product development team's blog is here -
    https://blogs.oracle.com/oracleb2bgurus/
    Regards,
    Anuj

  • New to java-need help for debugging

    hey there
    i just wanted my first program in java and here it is below with the error when i'm compiling it, i cant understand whats wrong:
    public class SquareArea {
    public static void main(String[] args); {
    float length;
    float width;
    float SquareArea;
    System.out.println ("Please enter length"+ length);
    System.out.println ("Please enter width"+ width);
    SquareArea= length*width;
    System.out.println ("The area of the square is" + SquareArea);
    The error is:C:\Documents and Settings\User\Desktop\SquareArea.java:5: missing method body, or declare abstract
    public static void main(String[] args); {
    ^
    1 error
    Tool completed with exit code 1

    Reading inputs from the command line is a bit complicated in java, here is how it is done:
    first add the line:
    import java.io.*;to the beginning of your program.
              float length;
              float width;
              float SquareArea;
              BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
              try
                   System.out.println ("Please enter length:");
                   String lengthStr = reader.readLine();
                   length = Float.parseFloat(lengthStr);
                   System.out.println ("Please enter width");
                   String widthStr = reader.readLine();
                   width = Float.parseFloat(widthStr);
                   SquareArea= length*width;
                   System.out.println ("The area of the square is" + SquareArea);
              catch (IOException ioe)
                   System.out.println("Error reading values.");
                   ioe.printStackTrace();
              }

  • New to Java -- Need to know if something is possible

    We have an application in which some complex calculations are being done in MatLab. In order to speed things up, we are converting it to C/C++. But there is also a GUI in the MatLab code. This is all to run on Windows.
    We will eventually (2 - 4 months from now, after it has been successfully converted and running) need to also port it to Linux. I am thinking that I would like to write the GUI portion in Java, so that it can be easily transferred from Windows to Linux.
    There is also an "embedded" portion running in C/C++. This must remain in C++ in because it is a real-time application where literally each microsecond will matter, Java will be too slow. In addition, some of the calculations will run on a parallel processing board, and the COTS libaries that support running on the card are C/C++ libraries.
    So, what I want is, to make a Java GUI that I can move from Windows to Linux, and in this GUI, each of the callbacks will then do nothing but call a C++ routine. I need the C++ routine to run completely independent of the Java Virtual Machine, to preserve the speed of the C++ library.
    My questions:
    If I write the GUI in Java, and have separate libraries/fucntions in C/C++ that are compiled for both Windows and Linux, can the Java GUI call these, and will they run as fast as they would in a normal C++ app? Or will it be slowed down by the JVM, and run at "interpreter speed"?
    How do you call the C++ code from inside a Java interpreter? Do we compile it all in a dll, and the dll is called from Java? Do we make a C++ library, and that can be called from the Java GUI? Or is there something else. This must have been done many times, does anybody have any suggestions or experience to get me going. I think I can glom together a simple Java GUI ( I produced some Java programs several years ago), and I can get the C++ libraries going, it is connecting them that I could use some guidance.
    Thanks.
    - Martin

    georgemc wrote:
    DrLaszloJamf wrote:
    georgemc wrote:
    DrLaszloJamf wrote:
    georgemc wrote:
    Ignore the myth that Java executes slowly because it's "interpreted". It's notHear, hear. Brian Goetz is a good source of Java myth debunking. Check out his columns:
    http://www.ibm.com/developerworks/views/java/libraryview.jsp?search_by=practice:
    Indeedie. Here's his article I like to trot out on occasions such as this
    http://java.sun.com/developer/technicalArticles/Interviews/goetz_qa.html
    I love to point out on some benchmarks, Java can be faster that C. "Faster than C? That's impossible!", people sputter, as if C were a physical constant, like the speed of light -- that's "c", folks!That's borne out of the misconception that any operation in Java is simply translated by the runtime into a similar operation in native code, and, were that the case, they'd probably have a point. It completely ignores runtime optimizationsAnd other things like Java's object allocation/GC being superior to malloc(), ...

  • New to Java-Need book that explains OOP concepts

    Hi-
    This as a great forum!
    I have been programming in VB for a while and now I'm trying to learn Java. Can someone please tell me which book is best for learning concepts like objects, classes, visibility etc; Most of the books I have seen go too fast or do not cover enough detail. I would like to find something that has lots of examples (diagrams are nice) and covers OOP thoroughly.
    Thanks!
    Ken

    The "Head First" books might be a good, gentle intro:
    http://www.amazon.com/Head-First-Object-Oriented-Analysis-Design/dp/0596008678/ref=pd_bbs_sr_1/104-1237750-7651950?ie=UTF8&s=books&qid=1184865003&sr=8-1
    %

  • New to BW Need Assistance

    Hi all! I've just been assigned to a BW project and have been given a short introduction to BW. I've been doing some reading but I need help on how to go about creating reports. How to use Bex and the Modeling Tool. How to go about creating an infosource, infoprovider, infocube. I tried looking up the documentation at help.sap.com but the link is not working and I'm just getting a blank page. I would really appreciate all your help.
    Thanks in advance!

    I started a month ago in a BW project, so I may know your issues.
    Another good place to start:
    https://www.sdn.sap.com/irj/sdn/developerareas/bi?rid=/webcontent/uuid/ee14e25d-0501-0010-11ad-8eb2861a7ec0 [original link is broken]
    and the general BI Startpage on sdn
    https://www.sdn.sap.com/irj/sdn/developerareas/bi
    The first week, there will be a lot to read for you,
    so make a huge cup of coffee and have fun.
    greets

  • New to Flash need assistance with autoplay

    I purchased a template from template monster that has a Flash Intro. It has a header with a previous and next button and three photos.  When the site loads up the first photo drops into place and text flies out from the sides of the photo then when you hit the next button the next photo drops in with its text and so on.  I was able to change the photos and text and all works fine.  What I want is for the banner to automatically rotate these three images and texts every 4 seconds or when someone hits those next or previous buttons.
    Right now the images/text only move if you hit the next or previous buttons.  Can someone please point me in the right direction to get this to automatically move by itself.
    In dreamweaver I set the Flash to autoplay and loop but that did nothting.

    use setInterval (as2) or the timer class to call the next button's onRelease().  (be sure to clear and re-set/re-start the interval/timer when the next or previous button is clicked).

Maybe you are looking for

  • Adobe Premiere CS2 Export Problem.

    I'm running Adobe premiere CS2 on a windows XP machine, and I'm having trouble exporting are Sunday services. I'm encoding them into Adobe with a Matrox RT. Here's my problem, I can export the message part of the service fine which is about 20 to 30

  • Blocking of post goods isssue in the delivery

    Is there any provision of blocking at post goods issue level in the delivery. if there pl explain entire process.

  • Exporting a library with its folders and albums

    I scanned over 1700 slides into my aperture library.  AFter spending a considerable amount of time putting them into folders and albums, I would like to export the project so my husband can put it into his aperture library.  I exported the whole proj

  • Web based admin pages broken on Mac?

    Have new WRT54GL v 1.1, 4.30.7 firmware. I have noticed intermittent problems with the web-based admin pages, using both Firefox and Safari on the Mac. Odd bit is these don't happen all the time and I'm not sure yet what triggers the problems. Most c

  • Set control value method

    How do I use the set control value method to send a cluster to a sub-vi? I have tried just sending the cluster as it is, but the invoke method gave me an error. I have thought about sending in the Control[] property of the cluster, and then in the su