JustAnswer > Programming
Ask A Question|Register|Login|Help
JustAnswer

Programming

Ask a Programming Question, Get an Answer ASAP!

Have your own Programming question?

6 Programmers are Online Now
characters left:
Not a Programming Question?

Related Programming Topics:

  • Add
  • ,
  • Run
  • ,
  • Two
  • ,
  • Back
  • ,
  • Code
  • ,
  • File
  • ,
  • Html
  • ,
  • Line
  • ,
  • Link
  • ,
  • Java
Bookmark and Share

Question

To ANSH

Submitted: 183 days and 4 hours ago.
Category: Programming
Value: $45
Status: CLOSED
+
Read More

Optional Information

OS: Windows XP; Browser: Netscape

Already Tried:
________________________________________
Design and implement a basic console application that implements the requirements stated below.
1.     Minimum requirements:
o     Design and implement your main method, in the class Lab4, in the file Lab4.java, to perform the following:
1.     If the file to load is not present on the command line, prompt the user using a JOptionPane for the file to process.
2.     Using an instance of the RectangleFile class:
1.     Load the final file into a Rectangle[]
2.     Output the populated Rectangle[] to System.out
3.     Find the minumum and maximum Rectangles in the Rectangle[]
o     Modify the Rectangle class from Lab 3 as follows:
?     Add a contructor that takes the width, length and color
?     Add an accessor method for the color
?     Add a mutator method for the collor
o     Design and implement class named RectangleFile, in the file RectangleFile.java, with the following methods:
?     Default no argument constructor
?     loadArrayFromFile:
?         /**
?          * If the given file exists:
?          *   - count the number of lines in the file
?          *   - create an appropriate size Rectangle[] to populate
?          *   - read in the file one line at a time where each line is formatted as:
?          *     width length color
?          *   - create a new Rectangle from the input and add it to the Rectangle[] that will be returned
?          *   - output a message to System.out with each new Rectangle object added to the array
?          * If the given file does not exist, write an appropriate error message to System.out
?          * @param filename the name of the file containing the raw Rectangle data
?          * @return the array of Rectangle objects created from the raw data in the file or null on error
?          * @throws java.lang.Exception - NOTE: we have not covered Exceptions yet so just add throws Exceptions on faith.
?          */
?         public Rectangle[] loadArrayFromFile(String filename) throws Exception
              
?     dumpArray:
?         /**
?          * Vali

Posted by Ansh P. 183 days and 4 hours ago.

Info Request

Ok I am working on this, but you posted 3 topics with my name the other 2 don't have any sort of questions. Please post the questions related to those if they have. Thank you.

183 days and 4 hours ago.

Reply


Glich in the internet..Design and implement a basic console application that implements the requirements stated below.

  1. Minimum requirements:
    • Design and implement your main method, in the class Lab4, in the file Lab4.java, to perform the following:
      1. If the file to load is not present on the command line, prompt the user using a JOptionPane for the file to process.
      2. Using an instance of the RectangleFile class:
        1. Load the final file into a Rectangle[]
        2. Output the populated Rectangle[] to System.out
        3. Find the minumum and maximum Rectangles in the Rectangle[]
    • Modify the Rectangle class from Lab 3 as follows:
      • Add a contructor that takes the width, length and color
      • Add an accessor method for the color
      • Add a mutator method for the collor
    • Design and implement class named RectangleFile, in the file RectangleFile.java, with the following methods:
      • Default no argument constructor
      • loadArrayFromFile:
  • § /**
  • § * If the given file exists:
  • § * - count the number of lines in the file
  • § * - create an appropriate size Rectangle[] to populate
  • § * - read in the file one line at a time where each line is formatted as:
  • § * width length color
  • § * - create a new Rectangle from the input and add it to the Rectangle[] that will be returned
  • § * - output a message to System.out with each new Rectangle object added to the array
  • § * If the given file does not exist, write an appropriate error message to System.out
  • § * @param filename the name of the file containing the raw Rectangle data
  • § * @return the array of Rectangle objects created from the raw data in the file or null on error
  • § * @throws java.lang.Exception - NOTE: we have not covered Exceptions yet so just add throws Exceptions on faith.
  • § */
  • § public Rectangle[] loadArrayFromFile(String filename) throws Exception

      • dumpArray:
  • § /**
  • § * Validate the rectangles array and then for each Rectangle in the array, add its toString output to
  • § * a StringBuffer
  • § * @param rectangles the array of Rectangle objects to process
  • § * @return a single string with each Rectangle object's toString result on its own line
  • § */
  • § public String dumpArray(Rectangle[] rectangles)

      • findAndOutputMinMaxRectangle:
  • § /**
  • § * Validate the rectangles array and then iterate through the array to find the
  • § * Rectangle object with the minimum and maximum area and the index in the array
  • § * they were found out and output to System.out the search results to include the
  • § * index, the Rectangle object and an appropriate message.
  • § * @param rectangles the array to process
  • § */
  • § public void findAndOutputMinMaxRectangle(Rectangle[] rectangles)

      • countLinesInFile:
  • § /**
  • § * Read the given file line at a time and count all non-empty lines read. Before returning, output a
  • § * message to System.out detailing the file that was processed and the number of lines counted.
  • § * @param fileToCountLines the File instance to process
  • § * @return the number of non-empty lines in the file
  • § * @throws java.lang.Exception - NOTE: we have not covered Exceptions yet so just add throws Exceptions on faith.
  • § */
  • § private int countLinesInFile(File fileToCountLines) throws Exception

    • Sample System.out output when the file was found:
  • o Given the following contents in a file named rectangles.txt:
  • o 1.5 21.5 red
  • o 2.5 22.5 white
  • o 3.5 23.5 blue
  • o 4.5 24.5 red
  • o 5.5 25.5 white
  • o 6.5 26.5 blue
  • o 7.5 27.5 red
  • o 8.5 28.5 blue
  • o 9.5 12.5 red
  • o 10.5 11.5 blue
  • o 11.5 10.5 red
  • o 12.5 9.5 white
  • o 13.5 8.5 white
  • o
  • o and executed with the command line: java Main rectangles.txt
  • o
  • o Produced the following output:
  • o
  • o countLinesInFile: File=rectangles.txt Lines=13
  • o loadArrayFromFile: Adding Rectangle: Width=1.5000 Length=21.5000 Color=red Area=32.2500 Perimeter=46.0000 at index 0
  • o loadArrayFromFile: Adding Rectangle: Width=2.5000 Length=22.5000 Color=white Area=56.2500 Perimeter=50.0000 at index 1
  • o loadArrayFromFile: Adding Rectangle: Width=3.5000 Length=23.5000 Color=blue Area=82.2500 Perimeter=54.0000 at index 2
  • o loadArrayFromFile: Adding Rectangle: Width=4.5000 Length=24.5000 Color=red Area=110.2500 Perimeter=58.0000 at index 3
  • o loadArrayFromFile: Adding Rectangle: Width=5.5000 Length=25.5000 Color=white Area=140.2500 Perimeter=62.0000 at index 4
  • o loadArrayFromFile: Adding Rectangle: Width=6.5000 Length=26.5000 Color=blue Area=172.2500 Perimeter=66.0000 at index 5
  • o loadArrayFromFile: Adding Rectangle: Width=7.5000 Length=27.5000 Color=red Area=206.2500 Perimeter=70.0000 at index 6
  • o loadArrayFromFile: Adding Rectangle: Width=8.5000 Length=28.5000 Color=blue Area=242.2500 Perimeter=74.0000 at index 7
  • o loadArrayFromFile: Adding Rectangle: Width=9.5000 Length=12.5000 Color=red Area=118.7500 Perimeter=44.0000 at index 8
  • o loadArrayFromFile: Adding Rectangle: Width=10.5000 Length=11.5000 Color=blue Area=120.7500 Perimeter=44.0000 at index 9
  • o loadArrayFromFile: Adding Rectangle: Width=11.5000 Length=10.5000 Color=red Area=120.7500 Perimeter=44.0000 at index 10
  • o loadArrayFromFile: Adding Rectangle: Width=12.5000 Length=9.5000 Color=white Area=118.7500 Perimeter=44.0000 at index 11
  • o loadArrayFromFile: Adding Rectangle: Width=13.5000 Length=8.5000 Color=white Area=114.7500 Perimeter=44.0000 at index 12
  • o Rectangles Array Contents:
  • o Rectangle: Width=1.5000 Length=21.5000 Color=red Area=32.2500 Perimeter=46.0000
  • o Rectangle: Width=2.5000 Length=22.5000 Color=white Area=56.2500 Perimeter=50.0000
  • o Rectangle: Width=3.5000 Length=23.5000 Color=blue Area=82.2500 Perimeter=54.0000
  • o Rectangle: Width=4.5000 Length=24.5000 Color=red Area=110.2500 Perimeter=58.0000
  • o Rectangle: Width=5.5000 Length=25.5000 Color=white Area=140.2500 Perimeter=62.0000
  • o Rectangle: Width=6.5000 Length=26.5000 Color=blue Area=172.2500 Perimeter=66.0000
  • o Rectangle: Width=7.5000 Length=27.5000 Color=red Area=206.2500 Perimeter=70.0000
  • o Rectangle: Width=8.5000 Length=28.5000 Color=blue Area=242.2500 Perimeter=74.0000
  • o Rectangle: Width=9.5000 Length=12.5000 Color=red Area=118.7500 Perimeter=44.0000
  • o Rectangle: Width=10.5000 Length=11.5000 Color=blue Area=120.7500 Perimeter=44.0000
  • o Rectangle: Width=11.5000 Length=10.5000 Color=red Area=120.7500 Perimeter=44.0000
  • o Rectangle: Width=12.5000 Length=9.5000 Color=white Area=118.7500 Perimeter=44.0000
  • o Rectangle: Width=13.5000 Length=8.5000 Color=white Area=114.7500 Perimeter=44.0000
  • o
  • o
  • o The Rectangle at index 0 has the minimum Area is Rectangle: Width=1.5000 Length=21.5000 Color=red Area=32.2500 Perimeter=46.0000
  • o The Rectangle at index 7 has the maximum Area is Rectangle: Width=8.5000 Length=28.5000 Color=blue Area=242.2500 Perimeter=74.0000

    • Sample System.out output when the file was not found:
  • o Executing with the command line with an invalid filename: java Main rect.txt
  • o
  • o Produced the following output:
  • o
  • o loadArrayFromFile: rect.txt could not be found
  • o dumpArray: The array is null!
  • o findAndOutputMinMaxRectangle: the array is null
  • o

  1. Minimum general design requirements:
    • You will follow the Java naming conventions, i.e., class names are in Pascal case, i.e., CheckingAccount; methods and variables are in Camel case, i.e., getOverdraftLimt().

 

Posted by Ansh P. 183 days and 4 hours ago.

Info Request

Ok there are how many questions?

183 days and 4 hours ago.

Reply

just this one

 

Posted by Ansh P. 183 days and 4 hours ago.

Info Request

Ok seems like a big program, I will let you know about the work involved. Hoping that you will compensate if efforts are bigger than expectation.

183 days and 4 hours ago.

Reply

ABSOLUTELY!!!

Posted by Ansh P. 183 days and 4 hours ago.

Info Request

Thank you. I will finish this up as soon as possible and let you know. :)

183 days and 4 hours ago.

Reply

THANKS!!

Posted by Ansh P. 182 days and 20 hours ago.

Info Request

I am working on this. Just need a bit of time. Be assured, I will finish it within the stipulated time.

182 days and 7 hours ago.

Reply

No problem! I now you will!

Thanks!!!

Posted by Ansh P. 181 days and 21 hours ago.

Answer

Ok here is the program: http://rapidshare.com/files/237106101/java_files.rar.html

 

Note: I have password protected this file, after you download it just reply here and I will sent you the password.

 

Hoping that you will compensate me well for my extra time and effort.



Edited by Ansh P. on 5/25/2009 at 4:29 PM

181 days and 1 hours ago.

Reply

I will do this once I get home!

THANKS!!!

Posted by Ansh P. 180 days and 21 hours ago.

Info Request

Ya sure. Keep me informed. :)

178 days and 9 hours ago.

Reply

Sorry I have been having internet problems. Can I get the password now?

Thanks!

Posted by Ansh P. 178 days and 1 hours ago.

Answer

No problem at all, I was guessing you are having some sort of problem. The password is anshp

178 days and 1 hours ago.

Reply

THANKS!!! Again I will chack at home!!!

Posted by Ansh P. 178 days and 1 hours ago.

Info Request

Have you saved the file?, I have deleted it from server. If you need that again do tell me.

177 days and 4 hours ago.

Reply

I do need it. can you put it back on and have the same password???

Posted by Ansh P. 176 days and 4 hours ago.

Answer

Here is the file: http://rapidshare.com/files/239173174/java_files.rar.html

 

Download and save it and do reply me.

 

175 days and 8 hours ago.

Reply

ÏI keep getting the following:

 

Lab4.java:98: cannot find symbol
ÏϧÏsymbol : class RectangleFile
ÏϧÏlocation: class Lab4
ÏÏ§Ï RectangleFile rf = new RectangleFile();

 

ÏRectangleFile.java:34: cannot find symbol
ÏϧÏsymbol : class Rectangle
ÏϧÏlocation: class RectangleFile
ÏÏ§Ï public Rectangle[] loadArrayFromFile (String filename) throws Exception

Posted by Ansh P. 175 days and 7 hours ago.

Answer

This is because you are trying to compile it directly from within the extractor(WinZip/WinRar). First of all extract all the files from the rar to the hard drive and than try to compile, this code is fully tested and works as smooth as air. :)

175 days and 3 hours ago.

Reply

I thought I did that. I'm at work and will try once I am at home.

Posted by Ansh P. 174 days and 22 hours ago.

Info Request

Ya sure and let me know. I also tried to compile directly from the rar and got the same error.

174 days and 13 hours ago.

Reply

I'm at a loss. I have saved it and I am getting the following

Extracting Lab4.class Blocked by Windows

Extracting Lab4.class Interrupted

Posted by Ansh P. 174 days and 8 hours ago.

Answer

New download link(this should not give any errors): http://rapidshare.com/files/239845663/java_files.rar.html

 

 

173 days and 23 hours ago.

Reply

I'm at a loss. I have tried opening the files and get the following when I try and complie and run lab 4

ÏLab4.java:98: cannot find symbol
ÏϧÏsymbol : class RectangleFile
ÏϧÏlocation: class Lab4
ÏÏ§Ï RectangleFile rf = new RectangleFile();

when I complie rectangle I get

Rectangle.java:98: cannot find symbol
ÏϧÏsymbol : class RectangleFile
ÏϧÏlocation: class Lab4
ÏÏ§Ï RectangleFile rf = new RectangleFile();

And then when I try and save the two lab4 overides andwants to be saved as rectangle?

Accepted Answer

I guess you are not extracting the files and trying to run them.

 

I will give you the instructions in details.

 

http://rapidshare.com/files/240067054/Lab4.java.html

http://rapidshare.com/files/240067414/RectangleFile.java.html

http://rapidshare.com/files/240067733/rectangles.txt.html

 

Download these java source files, and save all of them in a single folder. Now open them using the compiler. First of all compile the Lab4.java file and when it finishes, compile the RectangleFile.java. Now run the Lab4.java file. Hope this helps.

 

Picture
Expert: Ansh P.
Pos. Feedback: 95.0 %
Accepts: 
Answered: 6/2/2009

Computer Software Specialist

Professional software developer and working as a system engineer in top multi national company.

173 days and 5 hours ago.

Reply

I'm sorry I have been such a pain. I will try later when I am at home.

THank you again!!!

Posted by Ansh P. 172 days and 20 hours ago.

Info Request

No problem at all, it always feels good to help. :)

171 days and 6 hours ago.

Reply

IT WORKED!!!!!

This is what was posted for the last one....can you help me to see if this one is similiar? DOes that make sense?

Click here to download file
http://rapidshare.com/files/241019069/Main.java.html

http://rapidshare.com/files/241019385/Rectangle.java.html

 

Posted by Ansh P. 170 days and 20 hours ago.

Answer

Ya you can say, Do this:

 

First, compile Rectangle.java file > than compile the Main.java file > Run the Main.java file.

 

Hope this helps. :)

170 days ago.

Reply

Did you have a chance to look at the file I sent and the one you sent?

+
Read More

Related Programming Questions

  • assembler lc3
  • I tried to change in the options tab "general" the start up
  • My second c++ problem
  • Question re: cpanel and linking pages from home page
  • Can you provide the drivers log database for this post: htt...
  • this is my first java programming class and I have to write
  • I am doing a project that is using the vlookup function and
  • What happens if you call a function and you don't do anythin...



Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.
Question List | Become an Expert | Terms of Service | Security & Privacy | About Us
© 2003-2009 JustAnswer Corp.