aspose file tools*
The moose likes Java in General and the fly likes need help i have assighment to finish before end of day Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

need help i have assighment to finish before end of day

swatantra sohni
Greenhorn

Joined: Sep 16, 2007
Posts: 4
1. Construct a class ReverseContent, which makes a copy of the input file.
Read each line in the file and print the line in the reverse order in the copied file.
If the file is blank give an error message that the input file is blank.

2. Construct a class FileCreation, which takes NAME & Some String value from User. Then creates a file
with name as <NAME>_<TODAY_DATETIME in the format 20070905163004> and write the string value the user has given to the file.
Once it is written successfully, as a next method parse the file and read the file content and print it to the console

3. Construct a program WordCount, which counts number of chars, words and lines of the text file. Space is
counted as a character. Empty rows are counted as lines. "Word" will represent a string. Method Character.isLetter(char ch) might be useful? Look at the java.lang.Character from Java API documentation!

4 Write and run a Java program that enters an 8-digit string for a birthdate from the keyboard. The first
two digits in the string are the month of birth, the next two are the day and the remaining four are the year. The Java program should squeeze out these substrings and display it on the screen as follows:
month of birth:
day of birth:
year of birth:
Also display the input date of birth in the format 4th September 2007

Try to add exception handling for the case if the month and day are out of range.

5. Write a text file counter.dat which contains the integer 0. Then write a Java application that reads
this file and increments the integer by one. Then the new integer is written back to the file counter.dat . This means every time we open and close the file the integer number is incremented by 1.

6. Write a Java application using two for loops to produce the following pattern of asterisks.
*
**
***
****
*****
******
*******
********

7. Read in three integers of data type long from the keyboard. Then add the three numbers. Type convert
the sum to data type double and divide by 3.0 (data type double ) to find the arithmetic mean.


pls help nd provide codes/ideas ASAP
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
Well, the idea is that people here help when you get stuck.
So, when you have written the code, but it does not work as expected, or when you get stuck at a specific point, people will be happy to point you to the right direction.
However this is not the right place when you expect people to give you the solution to an assignment just like that.
swatantra sohni
Greenhorn

Joined: Sep 16, 2007
Posts: 4
well what you saying is probably right......but you see am very new to java ....and still learing it.. and i have to give this off today..donot you think its a right place where you can people for help.........am sorry if i broke rules of forum.....!!!
swatantra sohni
Greenhorn

Joined: Sep 16, 2007
Posts: 4
well what you saying is probably right......but you see am very new to java ....and still learing it.. and i have to give this off today..donot you think its a right place where you can people for help.........am sorry if i broke rules of forum.....!!!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

Some hints:

1. Use BufferedReader to read the file line by line. Class StringBuilder (or StringBuffer) contains a method to reverse the text in a string.

2. Have a look at the classes in the package java.io (FileWriter, BufferedReader etc.) for more info on writing and reading files.

3. More file I/O, see again what I told you above. The question itself also gives a hint.

4. That one is easy. Look at the documentation of class String for useful methods to get out the substrings that you need to display.

5. More file reading and writing. See above.

6. This one should be very easy.

7. The mean of the numbers is the sum divided by 3. See class java.util.Scanner to read input from the keyboard.

Start with the exercises yourself. The point of the exercises is that you learn how to program and use Java. If we would simply give you the answer to your homework assignment, then we would not be helping you to lean Java. So, start working yourself, and if you get stuck then post your code here and explain exactly what it is you don't understand - then we can help you to learn.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
swatantra sohni
Greenhorn

Joined: Sep 16, 2007
Posts: 4
thanks you .......am coming up with code to discuss sooner!!!

keep posting!!!
Tamas Jano
Ranch Hand

Joined: Feb 21, 2007
Posts: 55
Originally posted by swatantra sohni:
thanks you .......am coming up with code to discuss sooner!!!

keep posting!!!


You keep quiet, the teacher might hear you.
Try to use punctuation correctly because that too as well as the attitude tell how badly you need help and what that means to you. At least pretend you care and appreciate the help you are given even if not deserved.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10926
    
  12

personally, i'd start with #6 or #7, as they seem the easiest (to me).


The most important tip I can think of: write your code in SMALL chunks. write 2-3 lines, compile it, then test it. whatever you do, DON'T try and write the whole program before you compile it for the first time. If you do that, you'll have dozens (if not hundreds) of compiler errors. If you do manage to fix them all, your program won't do what you want it to do - trust me.

if you write 2-3 lines and compile that, if there is an error, you know almost exactly where the problem is. Same goes for when you then test it. If you add one line and run your tests, then the problem is with that one line.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I am going to close this thread. If you would like any specific questions answered, please ask them in separate threads in the Java in General (beginner) forum.

Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help i have assighment to finish before end of day
 
Similar Threads
Java Beginner's I/O Question
I wanted to write a method that would return the year with the most number of hits as part of ex 4.3
Needs help in editing
NEED HELP
I dont get the "get and set" method for my homework