Results 1 to 4 of 4
Thread: Java Grade 11 Beginner Help
- 12-18-2011, 10:43 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 28
- Rep Power
- 0
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
B) 1.Ask user to enter a sentence and count how many th are in the sentence.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]); } }
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
- 12-18-2011, 11:44 AM #2
Senior Member
- Join Date
- Feb 2010
- Posts
- 128
- Rep Power
- 0
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.
- 12-18-2011, 04:40 PM #3
Member
- Join Date
- Dec 2011
- Posts
- 28
- Rep Power
- 0
Re: Java Grade 11 Beginner Help
The problem is that they do not function the way they should be therefore i have a error
-
Re: Java Grade 11 Beginner Help
Similar Threads
-
On bench marking the scalability of a Java server grade application
By prakashm in forum Advanced JavaReplies: 1Last Post: 10-08-2010, 02:00 PM -
Is Java ready for Carrier Grade Applications?
By Kate in forum Reviews / AdvertisingReplies: 0Last Post: 06-18-2010, 11:18 AM -
Help with JAVA (Grade Book)
By Sara_21 in forum New To JavaReplies: 3Last Post: 11-30-2009, 02:45 PM -
beginner grade 11-need help with RaceCar Game
By bobmasta5 in forum New To JavaReplies: 0Last Post: 01-09-2009, 09:04 PM -
beginner grade 11-need help with a math code involving returning values from a method
By bobmasta5 in forum New To JavaReplies: 3Last Post: 12-10-2008, 01:38 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks