Astrology Java Program- a tough question

I need someone to help me in my project...here is the question:
Write an astrology program. The user types in his or her birthday(month,day,year),
and the program responds with the user's zodiac sign, the traits associated with each sign
the user's age(in years,months,day), the animal sign for the year(e.g., Year of the Pig,
Year of the Tiger), the traits associated with each animal sign, and if the year is a leap
year or not. The dates covered for each sign can be searched through the horoscope section
of a newspaper or through the internet. Then enhance your program so that if the user is one
or two days away from the adjacent sign, the program outputs the nearest adjacent sign as well
as the traits associated with the nearest sign. The month may be entered as a number from 1 to 12
or in words, i.e.,January to December. Limit the year of the birthday from 1900 to 2010 only.
The program should allow the user to repeat the entire process as often as desired.
You can use this imports:
import java.text.DateFormat;
import java.util.Date;
import java.util.Calendar;
thanks for your reply! I am hoping for your kind consideration!

edit
1. Please continue in your [_earlier thread_|http://forums.sun.com/thread.jspa?threadID=5429726], don't flood the forum with your homework assignment.
2. Please confine your questions to the "New to Java" forum until such time as you can regard yourself as a Java Programmer.
I'm locking this thread and it will be removed later.
Edited by: DarrylBurke

Similar Messages

  • Java Programming Competition Sample Questions

    Hi,
    I am interested in participating the Java Programming Competition in my University. For pratice can you point me to some website with sample questions or any question u have in mind.
    Thanks
    Satish

    I was thinking of putting up on-forum competitions, winner gets dukes etc.
    Someone find an empty forum and we can get on it.

  • How to eliminate ^M in files thru java program

    Hi guys,
    SOS!!!
    I need to know how to eliminate ^M from files using a java program. This question was posted many times, but no one answered the question. Does anyone know the answer. Post the answer if anyone knows it.
    Thanks guys n gals.

    You need to create new strings with the /r stripped off
    /** Takes a string, and replaces the replace text with new text.
    * @param str String to replace into
    * @param pattern Pattern of text to replace.
    * @param replace What to replace it with.
    * @return str with the replace text replaced with the new text.
    protected static String replace(String str,String pattern, String replace) {
    int s = 0;
    int e = 0;
    StringBuffer result = new StringBuffer();
    while ((e = str.indexOf(pattern, s)) >= 0) {
    result.append(str.substring(s, e));
    result.append(replace);
    s = e+pattern.length();
    result.append(str.substring(s));
    return result.toString();
    }

  • Please help me in this tough problem in Java...im just new in Java program

    my teacher give this as a problem. so tough. we are just starting and we are now in control structures. please help me to finish this problem. And my problem is...
    Write an astrology program. The user types in his or her birthday(month,day,year),
    and the program responds with the user's zodiac sign, the traits associated with each sign
    the user's age(in years,months,day), the animal sign for the year(e.g., Year of the Pig,
    Year of the Tiger), the traits associated with each animal sign, and if the year is a leap
    year or not. The dates covered for each sign can be searched through the horoscope section
    of a newspaper or through the internet. Then enhance your program so that if the user is one
    or two days away from the adjacent sign, the program outputs the nearest adjacent sign as well
    as the traits associated with the nearest sign. The month may be entered as a number from 1 to 12
    or in words, i.e.,January to December. Limit the year of the birthday from 1900 to 2010 only.
    The program should allow the user to repeat the entire process as often as desired.
    You can use:
    import java.text.DateFormat;
    import java.util.Date;
    import java.util.Calendar;
    please...those who are genius out there in java program...help us to pass this project. Im begging! thanks!

    Frowner_Stud wrote:
    According to the second commandment: Thou shall not use the name of the Lord in vain.Is this not the definition of ironic, Mr. Morality?
    i am not cheating. And more of the same.
    we all know that an assignment is an assignment. a homework. homework means you can raise other help from somebody so that you will know the answer.You're not asking for "help" bucko, because you've been given decent help but have chosen to ignore it. No, you're asking for someone to do the work for you, and you may call it what you want, but in anyone else's book, that's cheating.
    dont be fool enough to reply if you dont know the reason why i am typing here Don't be fool enough to think that you can control who can or can't respond.
    because if you are in my part and if i know the answer there is no doubt that i will help you as soon as possible! Just because you have low morals doesn't mean that the rest of us do.
    Thanks for time of reading and God bless you including you family!and to you and yours. Have a blessed day.

  • Java Programming Language questions...???

    Hi everybody....
    Can I post here my questions about Java Programming Language....or only to to the relevant Sun's forum....http://forum.java.sun.com/index.jspa???
    My greetings,
    Simon

    Simon,
    sure, the worst thing that could happen is that people point you to the SUN forum. Usually this forum answers general Java questions.
    Frank

  • Java programming language main method question?

    Hello everyone I am quite new to the Java programming language and I have a question here concerning my main method. As you can see I am calling 4 others methods with my main method. What does the null mean after I call the method? I really don't understand is significance, what else could go there besides null?
    public static void main(String[] args)
              int cansPerPack = 6;
              System.out.println(cansPerPack);
              int cansPerCrate = 4* cansPerPack;
              System.out.println(cansPerCrate);
              have_fun(null);
              user_input(null);
              more_java(null);
              string_work(null);
         }Edited by: phantomswordsmen on Jul 25, 2010 4:29 PM

    phantomswordsmen wrote:
    ..As you can see I am calling 4 others methods with my main method. 'Your' main method? Your questions indicate that you did not write the code, who did?
    ..What does the null mean after I call the method?.. 'null' is being passed as an argument to the method, so there is no 'after the method' about it.
    ..I really don't understand is significance, what else could go there besides null? That would depend on the method signatures that are not shown in the code snippet posted. This is one of many reasons that I recommend people to post an SSCCE *(<- link).*
    BTW - method names like have_fun() do not follow the common nomenclature, and are not good code for a newbie to study. The code should be put to the pointy end of your sword.

  • Java Programming Question

    Hi,Everybody:
    I have a question about Java programming. If I want to write a java class code called if.java like below, how should I do to make it pass the java compiler and make it work. I know the words "if" and "for" are reserved words. I just try to figure it out that is it possible??? Do I need to create my own java compiler or recompiler?
    public class if
    public if() { }
    public static for test()
    return new for();
    public class for
    public for() { System.out.println("for class constructor"); }
    }

    I don't think you can bypass the compiler's rejection of this. There is little point to naming the classes after keywords. Not sure if it's case sensitive though, so maybe "If" or "For"? Otherwise, try "if_" or "for_"

  • Question about Java programming development

    There are five phases in java program development. They are: edit -> compile -> load -> verify -> execute
    However, every time I develops program. I only experience phase 1, phase 2 and phase 5. I always miss phase 3 and 4. When do the class loader and bytecode verifier work? How do they work?
    Second question, how the legitimate programs can execute automatically without typing command java to invoke the interpreter?

    lighthero wrote:
    I still have some questions.
    1. I want to run the program just like the commercial software such as Adobe and MS Office.(just double click to run the program.) How do I execute a java program without typing command java every time?Create an executable JAR: [http://java.sun.com/docs/books/tutorial/deployment/jar/index.html]
    >
    2. How does the JIT compiler work?[http://www.google.ca/search?q=Java+JIT]

  • Java Programming Questions

    I have taken a couple class in Java programming in just regular programming with GUI/console. I am looking to further my programming skills and wonder what course I need to take to become a java programmer for companies. I am confused on all this language in Java and there does not seem to be any reference to explain exactly what these technologies are. Example is.....What is J2EE? What is .JSP? Are they the same things? What environment is most commonly used in jobs? What about Java certifications?

    Here's the path tree to become a Java Programmer from Sun Microsystems:
    http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getlppage?page_id=212&path=SJPF
    There are other paths like Web Development and Databasing, so click around if you're interested in those. I think for a standard Java Programming job you will want the "Java Programming for Professionals - Sun Certified Java Programmer".
    However, most Jobs are specialized and require skills like JSP Development or Java Enterprise. Look around at a job search site and see what types of skills Java jobs are asking for.
    I've noticed, for example, that Java web jobs generally require: PHP, HTML, JSP, XML, SQL, etc.

  • Question about Java Program

    I have a question here that I cant seem to figure out.
    I would really appreciate it if someone would help me out with the answer. I just got started learning Java and have a question:
    Suppose list is an array of five components of the type int. What is stored in list after the following Java code executes?
    for(int index = 0; index < 5; index++)
    list(index) = 2 * index + 5;
    if(index % 2 ==0)
    list[index] = list[index] -3;
    I would really appreiciate it if someone could help me out with this problem.

    This doesn't seem like a JSC-related problem, but I'll answer it anyways...
    list(index) = 2 * index + 5;This should probably be list[index] = 2 * index + 5
    The array will, after execution, contain
    {2, 7, 6, 11, 10}

  • Accessing oracle DB from a java program - question for oracle driver

    Hi,
    I have Oracle 10 G under vista on my desktop. I am trying to write a simple java program to access/update database tables. I saw in one of oracle example to import 2 packages - namely --- import oracle.jdbc.driver.*; import oracle.sql.*;
    Where do I find these 2 packages. Also I read some documentation to download drivers. I would like to use 2 drivers, the thin driver and the OCI driver. Can someone tell me where I can find these drivers and where do I copy these two drivers - so javac and java command can recognize it.
    I will greatly appreciate the help. Julia
    My program is as follows
    (It was working few years ago but things have changed now and I have Vista because my old machine died):
    import java.sql.*; // JDBC package
    //import com.inet.tds.JDBCRowSet;
    import java.util.*;
    import oracle.jdbc.driver.*;
    import oracle.sql.*;
    public class HomeDB
    run as follows:
    C:\Documents and Settings\MMM>cd \jj
    C:\john>set CLASSPATH=.;c:\oracle9i\classes12;%CLASSPATH%
    C:\john>javac HomeDB.java
    C:\john>java HomeDB
    King: 24000.0
    Kochhar: 17000.0
    De Haan: 17000.0
    Hunold: 9000.0
    Ernst: 6000.0
    Austin: 4800.0
    public static void main(String[] argv)throws SQLException
    Connection conn=null;
    try // may throw a SQLException
    conn = getConnection();
    doQuery (conn);
    catch (SQLException e)
    System.err.println(e.getErrorCode() + ": " + e.getMessage());
    finally // make sure the connection is closed
    if (conn != null) try {conn.close();} catch (SQLException e) {};
    //out.close(); // close PrintWriter stream
    private static Connection getConnection() throws SQLException
    String username = "scott";
    String password = "tiger";
    String url = "jdbc:oracle:thin:@localhost:1521:newora";
    // "jdbc:oracle:thin:@localhost:1521:COCKYJOB";
    Connection conn = null;
    String driver = "oracle.jdbc.driver.OracleDriver";
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    } catch ( ClassNotFoundException cnfex ) {
    System.err.println(
    "Failed to load JDBC/ODBC driver." );
    cnfex.printStackTrace();
    }catch (Exception e){
    e.printStackTrace();
    //DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    conn = java.sql.DriverManager.getConnection(url,username,password);
    conn.setAutoCommit(false);
    return conn;
    private static void doQuery (Connection c) throws SQLException
    // statement to be executed
    String query = "SELECT ename, job, mgr FROM EMP";
    Statement st = null;
    ResultSet rs = null;
    try // make sure the close statements are executed (in the finally block)
    // create the statement
    st = c.createStatement();
    // execute the query
    rs = st.executeQuery(query);
    // process results
    while (rs.next())
    // get the employee last name
    String eName = rs.getString("ename");
    String eJob = rs.getString("job");
    String eMgr = rs.getString("mgr");
    System.out.println("Emp Name:" + eName +
    "Job: " + eJob +
    "MGR: " + eMgr);
    finally // make sure the close statements are executed
    // close the result set if it exists
    if (rs != null) try {rs.close();} catch (Exception e) {};
    // close the statement if it exists
    if (st != null) try {st.close();} catch (Exception e) {};
    Edited by: user455788 on Dec 19, 2008 9:13 PM

    You can download the drivers from http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html.
    Note that oracle.jdbc.driver is desupported after 10.2, http://forums.oracle.com/forums/ann.jspa?annID=201, so you might want to consider using a DataSource to provide Connections.
    E.G.
    {message:id=2819114}

  • Need help with Java programming installation question

    Sorry for my lack of knowledge about Java programming, but:....
    A while back I thought I had updated my Java Runtime Environment programming. But I now apparently have two programs installed, perhaps through my not handling the installation properly. Those are:
    J2SE Runtime Environment 5.0 update 5.0 (a 118MB file)
    and:
    Java 2 Runtime Environment, SE v 1.4.2_05 (a 108MB file)
    Do I need both of these installed? If not, which should I uninstall?
    Or, should I just leave it alone, and not worry about it?
    Yeah, I don't have much in the way of technical knowledge...
    Any help or advice would be appreciated. Thank you.
    Bob VanHorst

    Thanks for the feedback. I think I'll do just that. Once in a while I have a problem with Java not bringing up a webcam shot, but when that happens, it seems to be more website based than a general condition.

  • Java program question

    how would i write a java program that takes as input the distance of the commute in miles, the automobiles fuel consumption rate in miles per gallon, and the price of a gallon of gas. this program should then after output the cost of the commute.

    how would i write a java program that takes as input
    the distance of the commute in miles, the automobiles
    fuel consumption rate in miles per gallon, and the
    price of a gallon of gas. this program should then
    after output the cost of the commute.The same way anyone else would do it.

  • Running a java program a set number of times

    This is a general question. Is it possible to make a java program run only 5 times for the sake of arguement.
    Basically I want to write a program that will give the user some flexibility when it will actually run another Java program, but I only want them to be able to say "not now' for a set number of times. When the last time comes the other program will launch. I was initially thinking of the Do Whilw loop, but this needs to work when the program is restarted.
    Program starts, it has 5 times it will run before it does something else(doesn't really matter now I think). User takes option "Not Now" and the program ends, but warns the user this will run 4 more times before you will need to do something.
    This process will repeat until the user takes the option "Ok install now" or the time limit expires and the install occurs anyway. Can someone point me in the right direction.

    ok I see so it's like one those programs that you download for free on the internet and they give you a set amount times to use it before you have to pay for it. but in this case when the number of times you use it equals 5 (or when the user clicks ok) a different java app will open automatically.
    My first thought would be to Write a Serialized object to disk using objectOutputStream that stores the number of times the application has been opened. and each time the program runs it checks for the serialized object and then you can do something like what I posted before. of course if were worried about security the user could always look for the object and erase it, if so then I guess we would have to come up with another plan of attack
    Hope this helps

  • Running a Java program at startup in Linux

    Hello
    How do I run a Java program at startup in Linux? I know in Windows I can put a .bat file in C:\Windows\Start Menu\Programs\StartUp\ directory, but in Linux I have no idea how it is done.
    Thank you,
    Mihai

    This is really a Linux question, not Java.
    And then it depends on the version of Linux you are using.
    Maybe this will help, otherwise you should try on a forum for your version of Linux.

Maybe you are looking for