Pls help i have to give this assighment

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 provide codes/ideas ASAP

hi,
>>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. Solution to this problem:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class ReverseContent {
    /** Creates a new instance of ReverseContent */
    public ReverseContent() {
    public static void main(String args[])
        FileInputStream fin=null;
        FileOutputStream fout=null;
        try {
            if(!(args.length>=2))
                System.out.println("run as: java ReverseContent sourcefilepath destinationfilepath");
                return;
            fin=new FileInputStream(args[0]);
            fout=new FileOutputStream(args[1]);
            int temp=0;
            String content="";
            while((temp=fin.read())!=-1)
               content+=String.valueOf((char)temp) ;
            fin.close();
            content=content.trim();
            StringBuffer sbuf=new StringBuffer(content);
            sbuf.reverse();
            content=sbuf.toString();
            fout.write(content.getBytes());
            fout.flush();
            fout.close();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        catch(IOException ex){
            ex.printStackTrace();
        finally
            try {
                if(fin!=null)
                    fin.close();
                if(fout!=null)
                    fout.close();
            } catch (IOException ex) {
                ex.printStackTrace();
}

Similar Messages

  • I have a iPad 4 on iOS 7.0.4 and every time I go to the spotlight search my iPad would respring just after typing in one letter in the spotlight search bar and it keeps d..please help I have to give this iPad to my grandma for her birthday on January 6

    It would respring after typing in one letter at the spotlight search bar...how do I get rid of this...I have noticed this change about 1 day ago

    You will need to look elsewhere
    Jaigosh00 wrote:
    ... I think my cousin jailbroke the iPad without my knowing because there is a weird icon that says Cydia...
    Sorry... But...
    The discussion of Jailbroken Devices is against the Terms of Use of this Forum.
    Unauthorized modification of iOS  >  http://support.apple.com/kb/HT3743

  • HT1338 I AM HAVING SO MANY PROBLE TRYING TO DOWNLOAD Mac OS X version 10.7.5 TO MY MACBOOK, I NEED HELP, I HAVE ALREADY PURCHASE THIS PRODUCT OVER A MONTH AGO

    I AM HAVING SO MANY PROBLEMS TRYING TO DOWNLOAD Mac OS X version 10.7.5 TO MY MACBOOK, I NEED HELP, I HAVE ALREADY PURCHASE THIS PRODUCT OVER A MONTH AGO

    lkimmie wrote:
    I AM HAVING SO MANY PROBLEMS TRYING TO DOWNLOAD Mac OS X version 10.7.5 TO MY MACBOOK, I NEED HELP, I HAVE ALREADY PURCHASE THIS PRODUCT OVER A MONTH AGO
    Firstly, please turn off your Caps lock. It is considered shouting in forums.
    Secondly, please explain your exact issue and wheteher or not you can see your purchase in the App Store and if you are using the same Apple ID to reinstall it with as you used to purcase it with.
    Thanks
    Pete

  • HT1212 i have forgotten my password of itunes, i have taken backup of contacts but is unable to restore . pls help i have my important data in back up

    Dear Sir,
    I have forgotten my password of itunes, i have taken backup of contacts but is unable to restore . pls help i have my important data in back up.
    Waiting for reply
    Thanks

    Encrypted backup?
    Read here:
    http://support.apple.com/kb/TS5162
    If the backup you're trying to restore from is encrypted, you will not be able to use that backup if you can't remember the encrypted backup passcode.
    If on a Mac, & you elected to save the passcode to your Keychain, you can recover the passcode from your Keychain. Otherwise, your backup data is unrecoverable.
    While you can continue to sync/backup, if you can't remember it & want to remove it, you'll have to delete your existing backups, & restore your phone as a new device.
    You delete your existing backups here: iTunes>Preferences>Devices.

  • I have a huge black dust patch on my screen and support staff isn't helping. Pls help, i have a huge black dust patch on my screen and support staff isn't helping. Pls help

    i have a huge black dust patch on my screen and support staff isn't helping. Pls help, i have a huge black dust patch on my screen and support staff isn't helping. Pls help

    Bring it in to have it looked at.
    Or take a photo and use the advanced editor of the board to upload the image using the camera icon on the toolbar.

  • HT1766 i couldn't play my ipad as there is a window pop-out telling that my ipad hasn't been backed up in 2 weeks. Backups happen when this ipad is pluggud in, locked and connected to Wifi. Pls help to repair and solve this problem

    there is a window pop-out telling me that 'the ipad hasn't been backed up in 2 weeks. Backups happen when this ipad is plugged in, locked and connected to wifi". How to repair or solve this problem? I have tried to plug in the ipad into my laptop, but i cound not solve this problem too. Pls help.
    Thank you.
    Regards,
    Yong

    Do a device reset as outlined below. This will clear the message and allow you to use your device again.
    Device Reset (won't affect settings/data/music/apps/etc)
    1. Press and hold (& continue to hold) BOTH the Sleep/Wake button & the Home button.
    2. Continue to hold BOTH (ignoring any other messages that may show) until you see the Apple logo on the screen.
    3. Release BOTH buttons when you see the Apple logo and allow the device to boot normally.

  • Pls help I have Bapi error response scenario

    Hi  Experts,
         I am working ona scenario.
    Sender will drop the required file on XI directory and XI will pull the file and map it with the BAPI u2013 and crate time entries in SAP HR. If errors are encountered during the process they are returned to the client in a report or as erroneous file.
    1) sender will FTP the file to XI directory
    2) XI will send the file after validation with BAPI for time entry creation in SAP R/3.
    3) If there is an error encountered XI will get an error response from BAPI
    *4) The erroneous file is sent to XI directory for client to view*
    I have to write this error files on the Xi directory.
    *How will I capure the error response from BAPI. as we are interested only for failure messages and not the sucessful messages. How we filter the mesages in XI, we want to capyure only failed messages.*
    Please help me out wz this.
    Thanks

    Hello,
    Your situation it is quite common task so refer to this step-by-step wiki:
    File-RFC-File(Without BPM)
    http://wiki.sdn.sap.com/wiki/display/XI/File-RFC-File(Without+BPM)
    What concerns that you want receive only response with error this is also not problem. In all BAPI function you can find response code which differ for successful and unsuccessful processing. So only you need to do it is filter data in you scenario with ERROR response code, you can do this in condition section of receiver determination.
    And if you want you can adjust two response streams in XI, one for successfull processing and another one for error (also with filtering).
    BR,
    Dzmitry

  • HT4061 somebody help anybody pls help i have an ipad 2 in recovery mode and i have tried restoring it but its has not worked for a month plus now

    my ipad just keep seeing the cable pointing to the itunes logo what should i do

    Have you been through recovery mode?  If not, place your device into recovery mode as described here.  You may have to try this more than once to succeed.
    http://support.apple.com/kb/HT1808
    If you have been through this, take your device in to an Authorized Apple Service Center.

  • I can not set up my files, my programs. I need help I have been at this all day and already sent a question. I can't get this done Please help me.

    Last night Chrome and Google 1+ locked down my pc because I disconnected plus one. I could not even get to Norton. This morning I talked to Norton and they moved my system to FF, I have two accounts Donnie p grant and Donnell Grant. I play Mafia Wars and a browser must be compatible with Client Addon. I am a gamer and had always used FF but was having trouble and switched to Chrome. When Norton moved my files back to FF she downloaded them but I can't get everything back to where it should be and I do not understand so much of it. Please help me set my FF account back up. Thank you

    ''donngra [[#answer-685379|said]]''
    <blockquote>
    ''FredMcD [[#answer-685331|said]]''
    <blockquote>
    Your System Details shows;
    Installed Plug-ins
    Shockwave Flash 15.0 r0
    Shockwave Flash 11.5 r502
    Having more than one version of a program may cause issues.
    Grab the uninstaller from here:
    '''[http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-windows.html Uninstall Flash Player | Windows]'''
    '''[http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-mac-os.html Uninstall Flash Player | Mac]'''
    Then reinstall the latest version.
    Flash Player '''v16.0.0.296<br>https://www.adobe.com/products/flashplayer/distribution3.html'''
    Shockwave Director '''v12.1.6.156 http://get.adobe.com/shockwave/'''
    </blockquote>
    </blockquote>

  • Pls help me out anyone in this reagrd.

    1.How to identify the installed machine oracle is client or server class?....
    2.If i want to install the client version of oracle 11g on my machine, which radio button i need to select from Desktop Class and Server Class?....
    3.Does Oracle 11g Client needs any license in production environment?....
    4.Is there any way to get OLEDB Provider for Oracle in SSIS without installing oracle package?....

    087f6de3-c6cc-4100-ba53-dffdf59935d9 wrote:
    1.How to identify the installed machine oracle is client or server class?....
    2.If i want to install the client version of oracle 11g on my machine, which radio button i need to select from Desktop Class and Server Class?....
    3.Does Oracle 11g Client needs any license in production environment?....
    4.Is there any way to get OLEDB Provider for Oracle in SSIS without installing oracle package?....
    1 - It's not "client" vs. "server" class, it's "desktop" vs. "server".  There really is no definitive attribute that makes it one or the other.  The description of these terms is in the Installation Guide:  Search for "system class" at Installing Oracle Database
    2 - If you are actually offered that choice after selecting to install the client only, I would think it would be self-evident that a client usually runs on a desktop .....
    3 - no
    ====
    BTW, it would be really helpful if you would go to your profile and give yourself a recognizable name.  It doesn't have to be your real name, just something that looks like a real name.  Who says my name is really Ed Stevens?  But at least when people see that on a message they have a known identity.  Unlike the system generated name of 'ed0f625b-6857-4956-9b66-da280b7cf3a2', which is like going to the pub with a bag over your head.

  • Pls help on error on ereader "this document is protected by DRM ( adobe digital rights management ) and is not currently authorized for use with your adobe id

    how do i solve this in order for the e reader to open the file?“this document is protected by DRM ( adobe digital rights management ) and is not currently authorized for use with your adobe id
    thnaks

    This is something you will need to talk to the publisher of the document. They might have to do something to allow you to open the file. (If you changed Adobe ID since buying the file, for instance, they might have to allow for that).

  • I have iphone 5. Have no sound and home button is not working pls help., I have iphone 5. Have no sound and home button is not working pls help.

    My iphone 5 has just stopped giving any sound no ringtones, no key clicking or button sounds nothing at all. And the home button has stopped working. Has anyone heard of software 6.1.4 being corrupt Im just updating software at the moment to 7.1. If anyone can offer a pieace of advise would be much appreciated.
    MANY THANKS
    JAY

    The iPhone warranty is not international and as you purchased in
    Malaysia the warranty is only valid in Malaysia
    You could try taking to an iPhone Authorised service provider
    in India but there have been many similar posts to yours
    and I am not aware  of them assisting  with an iPhone from
    outside India

  • I receive an error when trying to convert PDF to word.  Pls help, I have a paid acct.

    I receive an error when trying to convert PDF to word.  Can someone advise on how to resolve?

    "an error" really doesn't tell us much.
    Assuming that you use the ExportPDF online service, I suggest that you Contact Customer Care - click on the Still need help? button to chat or talk with an agent.
    [topic moved to ExportPDF forum]

  • I ,have an iphone4 16gb ,brought in uk,it does not supports the india networks ,how to unlock it ,pls help me., I ,have an iphone4 16gb ,brought in uk,it does not supports the india networks ,how to unlock it ,pls help me.

    I ,have an iphone4 16gb ,brought in uk,it does not supports the india networks ,how to unlock it ,pls help me., I ,have an iphone4 16gb ,brought in uk,it does not supports the india networks ,how to unlock it ,pls help me.

    Have you asked your mobile phone operator to turn on roaming for you? and if you have you will need to turn on DATA ROAMING on the iPhone by going to SETTINGS > GENERAL > MOBILE DATA and turn on DATA ROAMING. You should then be able to see the various Indian Networks listed in SETTINGS > CARRIER and be able to make/receive calls.
    If you are in India and didn't ask for Roaming to be activated on your mobile account you're stuck until you return to the UK.
    OR
    If you have a 'locked' phone that is tied to the UK operator then you will need to find a phone shop that unlocks iPhones but beware this invalidates any Apple Warranty. If you are still in the UK then phone the mobile operator and ask then to unlock your iPhone which they usually do if its not in a contract with them or at the end of the contract period.
    Hope that helps a little, Andrew

  • I have a problem with my macbook after i pressed the power button the screen turns blue and nothing is happening with it! What can I do? Pls helps and thx btw

    I have a problem with my MacBook Pro, I pressed the power button and after that the apple noise came and the screen turned blue. What can I do and what happened? pls help & thx btw

    You may find this helpful:
    http://support.apple.com/kb/PH14061
    Ciao.

Maybe you are looking for

  • Need to replicate Portal /irj security setting

    Hi Folks, I am working on a Portal 6 - Web AS 6.40 SPS 21 I have strange proprietary application (I guess aspx) handling user authentication in the production Portal: whenever a user points the browser to the production portal public URL (say https:/

  • How to hard reset my ipad

    The top switch does not work to reset ipad How to reset without thisswitch

  • Firefox occasionally crashes, after restarting it app tabs disappear. 8.0.1

    From time to time, Firefox crashes. When I open Firefox again, my app tabs disappear. The problem is that I had more than 50 app tabs, and I really need them back, as I don't recall some sites' titles or addresses and I can't find them in history. Ho

  • Embedding unicode font problem

    Hi All,        I am developing a flex application for Tamil language. I want to use tamil text in all the controls. When I embed a tamil unicode font with the application, it doesn't render the text properly because of the glyphs. @font-face {       

  • Adobe Document Services URL problem

    Hi, I am trying to connect to the adobe document services to test the configuration, but getting the following kind of error: "Adobe document service can not be started". can somebody tell me how to resolve this? Thanks, Sunita.