Program Assignment #5 - CS 1050 Dr Tucker Programming...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 1050, Dr. Tucker Programming Assignment #5; Spring 2010 Feb 4/8 Due: Fri, Feb’ZEI'Qphlgl Number of points: 40 This programming assignment can be redone until Fri, Apr 2 Note: If you are handing in a revision, then hand in the original graded version(s) also. This program will be a revision of Programming Assignment #2 to use a class. (See handout: Interactive Average with a Class) Write a Java class that will have 3 private instance variables (of type double) for the lengths of the sides of a triangle. The Java class should contain methods as follows: 1. A constructor that initializes the instance variables to default values (your choice of values) (no parameters for this constructor) 2. A constructor with 3 parameters that initializes the instance variables to be the values of the parameters. 3. A method that allows the user to input the lengths of the sides of a triangle — include prompts - no error checking will be done 4. A method that outputs the lengths of the sides of the triangle along with a message 5. A method that returns the perimeter of the triangle 6. A method that returns the area of the triangle This class should be placed in a file that is separate from the class containing the main program. Write a Java program to do the following: (setup your program so that the steps are done in the order listed below). This code will be in‘a file that is separate from the one for the class above. Note that the main method should have perimeter and area as local variables. 1. Call a void method that Will output an explanation of what the program does. Include in the explanation that this program uses a class for the sides of a triangle and include your name. 2. Get the values of the lengths of the sides from the user - use method from the class 3. Calculate the perimeter of the triangle — use method from the class 4. Calculate the area of the triangle —- use method from the class 5. Use a void method to output, with appropriate messages: The lengths of the sides of the triangle - use method from the class, the perimeter of the triangle, and the area of the triangle. Style of your code should be similar to that of the first revised version of Interactive Average which was handed out. Be sure to include comments — programmer identification, assignment number, section, purpose, and a brief explanation of the methods should appear in the header comment. Include an explanation for all variables, parameters and methods. Hand in: A printed copy of the source code — both files - do not use screen prints. A screen print showing the output — you will need to type in 3 numbers that are the lengths of the sides of a triangle. ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern