Results 1 to 4 of 4
  1. #1
    dharav is offline Member
    Join Date
    Dec 2011
    Posts
    28
    Rep Power
    0

    Question Java Grade 11 Beginner Help

    Ok so our Teacher In school never gave us the example for the following task and i am really confused i wrote a bit of code but i am lost as of now i spent 5 hours on it with notes give and no hope
    This is the task

    A)Write a program that asks the user to enter a string, and output the characters in the odd and even positions on two separate lines,
    but make sure the characters are aligned with the original string.
    Example input: bookkeeping
    Output:
    b o k e i g
    o k e p n

    HERE IS WHAT I GOT RIGHT NOW FOR THIS TASK I THINK IM WAY OFF BUT I STILL TRIED
    Java Code:
    package Stringtask3;
    import java.util.Scanner;
    public class Stringtask3 {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		
    		String i;
    		int count=0;
    		Scanner keyboard=new Scanner (System.in);
    		System.out.println("Please Type Any Single Word");
    		i=keyboard.nextLine();
    		for(int k=0;k<i.length();k++){
    			count++;
    			str_array[0]=i.indexOf
    		}
    		System.out.println(count);
    		String[] str_array = new String[2]; 
    		str_array[0] = "Java String";
    		str_array[1] = "Java String Array";
    		     
    		System.out.println("Index 0: " + str_array[0]);
    		System.out.println("Index 1: " + str_array[1]);
    	}
    
    }
    B) 1.Ask user to enter a sentence and count how many th are in the sentence.
    2.Create a file with 5 sentences (One sentence in a line.) count how many th are in each

    Here is what i have for this part here.


    Java Code:
    package Stringtask4;
    
    import java.io.*;
    import java.util.*;
    public class Stringtask4 {
    
    	/**
    	 * @param args
    	 * @throws FileNotFoundException 
    	 */
    	public static void main(String[] args) throws IOException {
    		// TODO Auto-generated method stub
    		
    		int count =0;
    		String l1;
    		Scanner Keyboard= new Scanner (System.in);
    		System.out.println("Please Type a Scentece In");
    		l1=Keyboard.nextLine();
    		int ul=0;
    		
    		for(int i=0;i<length;i++)
    		
    			{
    			ul = l1.indexOf("th");
    			count++;
    			}
    		System.out.println(count+" th's found");
    		}
    		
    	
    		String line,line2,line3,line4,line5;
    		
    		 Scanner in = new Scanner (new File ("Lines.txt"));
    		 line=in.nextLine();
    		 line2=in.nextLine();
    		 line3=in.nextLine();
    		 line4=in.nextLine();
    		 line5=in.nextLine();
    		 System.out.println("These are the inputed 5 senteces from file \n");
    		 System.out.println(line+"\n"+line2+"\n"+line3+"\n"+line4+"\n"+line5);
    		 
    		 
    	}
    
    }
    Last edited by JosAH; 12-18-2011 at 03:45 PM. Reason: changed the [color] ... [/color] tags to [code] ... [/code] tags

  2. #2
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Posts
    128
    Rep Power
    0

    Default Re: Java Grade 11 Beginner Help

    Whats is the actual problem you are having?
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

  3. #3
    dharav is offline Member
    Join Date
    Dec 2011
    Posts
    28
    Rep Power
    0

    Default Re: Java Grade 11 Beginner Help

    The problem is that they do not function the way they should be therefore i have a error

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Java Grade 11 Beginner Help

    Quote Originally Posted by dharav View Post
    The problem is that they do not function the way they should be therefore i have a error
    This tells us nothing about the error or your problem. Please read my link below on how to ask smart questions for more information on what information we need if we're going to have a chance of helping you. Best of luck.

Similar Threads

  1. Replies: 1
    Last Post: 10-08-2010, 02:00 PM
  2. Is Java ready for Carrier Grade Applications?
    By Kate in forum Reviews / Advertising
    Replies: 0
    Last Post: 06-18-2010, 11:18 AM
  3. Help with JAVA (Grade Book)
    By Sara_21 in forum New To Java
    Replies: 3
    Last Post: 11-30-2009, 02:45 PM
  4. beginner grade 11-need help with RaceCar Game
    By bobmasta5 in forum New To Java
    Replies: 0
    Last Post: 01-09-2009, 09:04 PM
  5. Replies: 3
    Last Post: 12-10-2008, 01:38 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •