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 7 of 7

Thread: Choosing a bibliography style, Beginner Programmer question.

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Choosing a bibliography style, Beginner Programmer question.

    I am enrolled in an Intro to Computer Programming class, however my knowledge about computer programming is very slim and my professor isn't exactly the best at teaching. He has given us a homework assignment that I believe is about creating a java program to cite articles. I have NO idea where to start so any help would be greatly appreciated.

    This is the homework:
    due Feb 14, 11am...
    (biblio.java) assignment
    The primary purposes of this assignment are
    1. to get used to String class operations.
    2. to get used to switch conditional statement.
    The secondary purpose is to get used to bibliography styles.

    Your program must prompt users to choose the style of bibliography types (a for ACM, i for IEEE, l for LNCS, all others for default style).
    Your program then must print the correct style.
    e.g., suppose you want to cite the following article
    http://www.pds.ewi.tudelft.nl/pubs/papers/scicomp01.pdf

    Inputs:
    Author1 = "Henk J. Sips";
    Author2 = Kees van Reeuwijk";
    TITLE = "Java for Scientific Computation: Prospects and Problems"
    booktitle = "LSSC'01"
    PAGES = "236-246"
    YEAR = 2001

    Then based on the user's choice, your program must print

    ACM:
    Sips, H.J. and Reeuwijk, K.V. Java for Scientific Computation: Prospects and Problems. In Proceedings of LSSC. 2001, 236-246.

    IEEE:
    H.J. Sips and K.V. Reeuwijk, "Java for Scientific Computation: Prospects and Problems", in Proc. LSSC, 2001, pp.236-246.

    LNCS:
    Sips, H.J., Reeuwijk, K.V.: Java for Scientific Computation: Prospects and Problems. In LSSC(2001) 236-246

    default:
    Henk J. Sips, Kees van Reeuwijk. Java for Scientific Computation: Prospects and Problems. In Proceedings of LSSC'2001. pp.236~246

    ===================
    1. must use the String methods you learned in class.
    2. must use the switch conditional statements.


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Choosing a bibliography style, Beginner Programmer question.

    I'll give it to you, that kind of assignment brief quite lazy on your lecturers behalf (as an outsiders point of view anyway).
    What you need to do first is to write down the logic behind what he's asking, and note how you would solve it on paper.

    Then, once you have a firm idea of what needs doing, you can String mapping it into Java.
    To complete this, you might want to study the API docs for String.

    Here's something to get you started.
    public class TestHarness {
     
    	public static void main(String[] args) {
    		// Create a Scanner object
    		// Read input from user
     
    		// Start switch statment
    			// compare cases
    				// if case match - process input and save into a String
    				// to complete the above, look at methods such as split() and substring
    				// from the String class in the API
     
    		// println(print string content constructed inside switch statement)
    	}
     
    }
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. The Following User Says Thank You to newbie For This Useful Post:

    diagnonsense (February 11th, 2012)

  4. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Choosing a bibliography style, Beginner Programmer question.

    Thank you for your help!
    I believe I have a hang of the switch classes and scanner objects.

    I am trying to allow the program to ask the user for inputs in Author, Title, Title 2, etc. before they choose a bibliography style type but I am confused as to how I can do that. I assume the correct way of doing the assignment would be to ask the users for their inputs and then based on their bibliography choice output a line with the style they chose.

    Correct?

  5. #4
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Choosing a bibliography style, Beginner Programmer question.

    Yeah, as the last input prompt, ask them to specify the type.
    If you're using Java 7, then this can be a String, otherwise you will need to use integers, and just map numbers to types (i.e. 1 = ACM ).

    For the authors list, I suggest you only ask once, but ask for a delimiter in the input, for which you could then use the String.split() method to separate them.
    (i.e. comma or colon - "Input Authors: Charles H Hanks, William Cookie", split on the comma and store into an array - the length of that array would be 2)
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  6. The Following User Says Thank You to newbie For This Useful Post:

    diagnonsense (February 11th, 2012)

  7. #5
    Junior Member
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Choosing a bibliography style, Beginner Programmer question.

    Alright, thank you for your advice.
    I didn't do the string.split() method since we haven't learned that in class yet.

    But I'm getting an error that I'm unfamiliar with

    import java.util.Scanner;
     
    class biblio {
     
    	public static void main(String[] args) {
     
    				String author1;
    				String author2;
    				String TITLE;
    				String booktitle;
    				String pages;
    				String year;
    				String input;
    				char style;
    				Scanner keyboard = new Scanner(System.in);
     
    				System.out.print("Author 1: ");
    				author1 = keyboard.nextLine();
     
    				System.out.print("Author 2: ");
    				author2 = keyboard.nextLine();
     
    				System.out.print("Title: ");
    				TITLE = keyboard.nextLine();
     
    				System.out.print("Book number: ");
    				booktitle = keyboard.nextLine();
     
    				System.out.print("Pages: ");
    				pages = keyboard.nextLine();
     
    				System.out.print("Year Published: ");
    				year = keyboard.nextLine();
     
    				System.out.print("\nA = ACM\nI = IEEE\nL = LNCS\n\nNo choice will result in default style\nChoose a bibliography style: ");
    				input = keyboard.nextLine();
    				style = input.chatAt(0);
     
    				switch(style)
    				{
    					case 'a':
    					case 'A':
    						System.out.print(author1 + " and " + author2 + ". " + TITLE + ". " + "In proceedings of " + booktitle + ". " + year + ", " + pages + "." );
    				}
    	}
    }

    But I'm getting this error:
    biblio.java:37: cannot find symbol
    symbol  : method chatAt(int)
    location: class java.lang.String
    				style = input.chatAt(0);
    				             ^
    1 error

  8. #6
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Choosing a bibliography style, Beginner Programmer question.

    The method chatAt doesn't exist in the API for String, but I assume you mean to reference charAt
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  9. The Following User Says Thank You to newbie For This Useful Post:

    diagnonsense (February 11th, 2012)

  10. #7
    Junior Member
    Join Date
    Feb 2012
    Posts
    7
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Choosing a bibliography style, Beginner Programmer question.

    Wow, for some reason I keep typing that over and over. I can't believe I didn't catch that!
    Thank you.

Similar Threads

  1. beginner programmer trouble
    By scottey313 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 30th, 2011, 01:41 PM
  2. another assignment from beginner programmer trouble
    By scottey313 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 30th, 2011, 01:13 PM
  3. Beginner java programmer!
    By chrisivey1980 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: April 23rd, 2011, 04:06 AM
  4. Beginner Question
    By jrt224 in forum Loops & Control Statements
    Replies: 1
    Last Post: March 10th, 2011, 12:56 PM
  5. Beginner programmer... no idea how to implement this properly
    By rkrajnov in forum Java Theory & Questions
    Replies: 1
    Last Post: January 31st, 2011, 08:02 AM