Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: java

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java

    write a class namesd fibonacci which when called by the class CalcFib will calcul;ate the fibonacci sequence of numbers. the first two numbers in the Fibonacci sequence are 1 and should be accounted for in the constructor method. Every other number in the sequence is the sum of the two previous numbers numbers and a method(s) in Fibonacci should determinie them.CalcFib should prompt the user to enter a limit; the program will stop when the current number in the sequence is greater than or equal to this limit.here is what the user will see when the program is executed: this proogram is executed: enter a limit on the largest numbers to be displayes:50


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: java

    Do you have any specific questions about your assignment?
    Please post your code and any questions about problems you are having.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java

    need a program that works

    --- Update ---

    every on e is crashing

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: java

    every on e is crashing
    Copy the full text of the error messages and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java

    import java.util.*;
    import java.io.*;


    public class convertdate{
    public static void main(String[] args){

    System.out.print("Enter date to be converted: "); // Inputs the month, day, and year
    Scanner in = new Scanner(System.in);
    String date = in.next();
    String dte = date.trim(); // Trims the extra spaces

    int index1 = dte.indexOf(" "); // Creates the minimum space between the characters
    int index2 = dte.lastIndexOf(" , ");

    /* This is where the letters of the month are going to be stored at in the output as well as capitalizing the first letter of the month */
    String firstLetter = dte.substring(0,1);
    String otherLetters = dte.substring(10);
    String dte0 = firstLetter.trim().toUpperCase() + otherLetters.trim().toLowerCase();

    /* Trims the extra spaces from the date */
    String dte1 = dte0.trim().substring(0, index1);
    String dte2 = dte.trim().substring(index1 + 1, index1 + 5);
    String dte3 = dte.trim().substring(index2 + 1);

    System.out.println("Converted Date: " + dte2 + " " + dte1 + " " + dte3); // Gives the output of an accurate date without any extra spaces
    }
    }

    --- Update ---

    sorry this is the program that is giving alot of trouble now

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: java

    the program that is giving alot of trouble
    Please explain what the "trouble" is.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java

    Write a java program named ConvertDate that converts a date entered by the user into another form. the users inout will have the form
    month day, year

    the month will be one of the word january , february,.... the letters in the month may be lowercase or any mixture of the two . there must be spaces : 1 space before the month ,2 between the month and the day , 3 betwwen the day and the year and 4 after the year. it must then be converted to
    Day month year

    date: mAY 12 , 2000
    ConvertDate : 12 May 2000

    --- Update ---

    Write a java program named ConvertDate that converts a date entered by the user into another form. the users inout will have the form
    month day, year

    the month will be one of the word january , february,.... the letters in the month may be lowercase or any mixture of the two . there must be spaces : 1 space before the month ,2 between the month and the day , 3 betwwen the day and the year and 4 after the year. it must then be converted to
    Day month year

    date: mAY 12 , 2000
    ConvertDate : 12 May 2000

    import java.util.*;
    import java.io.*;


    public class convertdate{
    public static void main(String[] args){

    System.out.print("Enter date to be converted: "); // Inputs the month, day, and year
    Scanner in = new Scanner(System.in);
    String date = in.next();
    String dte = date.trim(); // Trims the extra spaces

    int index1 = dte.indexOf(" "); // Creates the minimum space between the characters
    int index2 = dte.lastIndexOf(" , ");

    /* This is where the letters of the month are going to be stored at in the output as well as capitalizing the first letter of the month */
    String firstLetter = dte.substring(0,1);
    String otherLetters = dte.substring(10);
    String dte0 = firstLetter.trim().toUpperCase() + otherLetters.trim().toLowerCase();

    /* Trims the extra spaces from the date */
    String dte1 = dte0.trim().substring(0, index1);
    String dte2 = dte.trim().substring(index1 + 1, index1 + 5);
    String dte3 = dte.trim().substring(index2 + 1);

    System.out.println("Converted Date: " + dte2 + " " + dte1 + " " + dte3); // Gives the output of an accurate date without any extra spaces
    }
    }

    --- Update ---

    Write a java program named ConvertDate that converts a date entered by the user into another form. the users inout will have the form
    month day, year

    the month will be one of the word january , february,.... the letters in the month may be lowercase or any mixture of the two . there must be spaces : 1 space before the month ,2 between the month and the day , 3 betwwen the day and the year and 4 after the year. it must then be converted to
    Day month year

    date: mAY 12 , 2000
    ConvertDate : 12 May 2000

    import java.util.*;
    import java.io.*;


    public class convertdate{
    public static void main(String[] args){

    System.out.print("Enter date to be converted: "); // Inputs the month, day, and year
    Scanner in = new Scanner(System.in);
    String date = in.next();
    String dte = date.trim(); // Trims the extra spaces

    int index1 = dte.indexOf(" "); // Creates the minimum space between the characters
    int index2 = dte.lastIndexOf(" , ");

    /* This is where the letters of the month are going to be stored at in the output as well as capitalizing the first letter of the month */
    String firstLetter = dte.substring(0,1);
    String otherLetters = dte.substring(10);
    String dte0 = firstLetter.trim().toUpperCase() + otherLetters.trim().toLowerCase();

    /* Trims the extra spaces from the date */
    String dte1 = dte0.trim().substring(0, index1);
    String dte2 = dte.trim().substring(index1 + 1, index1 + 5);
    String dte3 = dte.trim().substring(index2 + 1);

    System.out.println("Converted Date: " + dte2 + " " + dte1 + " " + dte3); // Gives the output of an accurate date without any extra spaces
    }
    }

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: java

    Please explain what problems you are having with the program.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.