ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 2 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 25 May 2017 My Price 9.00

use of proper Java constructs

The first programming assignment is a simple programming exercise, using the notions of class hierarchy, and reading input from a file. It involves writing a program that computes the cost for a collection of sale orders of different types. This program consists of four classes. The first class is the SalesOrder class, which contains the product name, unit cost expressed in decimal dollars, and the number of units in the order. It should have three methods:

  1. A constructor that allows the product name, unit cost, and number of units to be initialized.
  2. A method namedtotalCost that returns the total cost of the order.
  3. AtoStringmethod that returns a string containing theproduct name,unit cost, andnumber of unitsappropriately labeled.

The SalesOrder class has two subclasses. The first is DiscountedSalesOrder. It has an additional instance variable that contains the discount in whole percent for that order . It should have the same three methods:

  1. A constructor that allowstheproduct name,unit cost, number of units, and discount to be initialized.
  2. An overridden methodtotalCost that returns the total cost of the order.
  3. AtoStringmethod that returns a string containing theproduct name,unit cost, number of units, and discountappropriately labeled.

The second subclass is BulkOrder. It has an additional instance variable that reflects the minimum size of the order before discount. It should have the same three methods:

  1. A constructor that allowstheproduct name,unit cost, number of units, and minimum size  to be initialized.
  2. An overridden methodtotalCost that returns the total cost of the order. The total cost is computed with the following rules: no discount for units upto the minimum size, 10% discount for units above the minimum size and less than twice the minimum size, and 30% discount for all units after twice the minimum size.
  3. An overriddentoStringmethod that returns a string containing theproduct name,unit cost, number of units, and minimum size appropriately labeled.

Finally there should be a fourth class that contains the main method. It should read in sales order  information from a text file. Each line of the text file will represent the information for sales order. An example of how the text file will look is shown below:

SalesOrder,Product 1,100,10.25DiscountedSalesOrder,Product 2,50,200.10,20 BulkOrder,Product 1,1000,50.,300

The type of order is the first element . The file will contain order  information for an arbitrary number of products. You can assume that you do not have more than 100 orders in the file. Next are the name of the product, the number of units, and the unit cost. For discounted orders, the final value is discount. For bulk order, the final value is the minimum size. As orders are read in, SalesOrder objects of the appropriate type should be created and they should be stored in one array. You may also assume that the data in the file will be formatted correctly. You should not making any assumption about the ordering in that file.

Once all the sales order data is read in, a report should be displayed on the console for each product, in ascending order of total cost. Each line of the report should contain all original data supplied for each sales together with that order's total cost. After all lines are printed, the total of all sales for each product should be computed and displayed as well.

Be sure to follow good programming style, which means making all instance variables private or protected, naming all constants and avoiding the duplication of code. Furthermore you must select enough different kinds of sales orders to completely test the program.

Grading rubrics:

25%: requirements (5% for the completion of each class, 5% for the reading of the data from a file, 5% for printing the results correctly)

20%: test data and test documentation. Have 2 different examples of input files. Describe the expected output for each file in a document, and explain how you computed this expected output, independently of your program; just running your program and pasting the results does not count! Make sure that each test file covers all the requirements. Do not include test for correct input.

30%: code structure (use of proper Java constructs, no code repetition, variables as local as possible, appropriate use of instance variables and of class variables)

25%: code presentation. Fully spelled and meaningful names (variables, classes, functions), header comment with your full name and the assignment name, no useless comments (in particular the automatically generated comments), no useless imports, proper code indentation. 

When choosing class name, variable names, make sure to spell out all names, start class names with an uppercase letter, and variable names with lowercase letters, and use the camel notation (class MobilePhone, String phoneNumber for instance). Make sure to clean up generated comments too.

 

Homework 1InstructionsThe frst programming assignment is a simple programming exercise, using the notions oF classhierarchy, and reading input From a fle. It involves writing a program that computes the cost For acollection oF sale orders oF di±erent types. This program consists oF Four classes. The frst class istheSalesOrderclass, which contains the product name, unit cost expressed in decimal dollars, and thenumber oF units in the order. It should have three methods:1.A constructor that allows the product name, unit cost, and number oF units to be initialized.2.A method namedtotalCostthat returns the total cost oF the order.3.AtoStringmethod that returns a string containing the product name, unit cost, and number oFunits appropriately labeled.TheSalesOrderclass has two subclasses. The frst isDiscountedSalesOrder. It has an additional instancevariable that contains the discount in whole percent For that order. It should have the same threemethods:1.A constructor that allows the product name, unit cost, number oF units, and discount to beinitialized.2.An overridden methodtotalCostthat returns the total cost oF the order.3.AtoStringmethod that returns a string containing the product name, unit cost, number oF units,and discount appropriately labeled.The second subclass isBulkOrder. It has an additional instance variable that re²ects the minimum size oFthe order beFore discount. It should have the same three methods:1.A constructor that allows the product name, unit cost, number oF units, and minimum size to beinitialized.2.An overridden methodtotalCostthat returns the total cost oF the order. The total cost is computedwith the Following rules: no discount For units upto the minimum size, 10% discount For units abovethe minimum size and less than twice the minimum size, and 30% discount For all units aFter twicethe minimum size.3.An overriddentoStringmethod that returns a string containing the product name, unitcost, number oF units, and minimum size appropriately labeled.³inally there should be a Fourth class that contains the main method. It should read in salesorder inFormation From a text fle. Each line oF the text fle will represent the inFormation For sales order.An example oF how the text fle will look is shown below:SalesOrder,Product 1,100,10.25DiscountedSalesOrder,Product 2,50,200.10,20BulkOrder,Product 1,1000,50.,300The type oF order is the frst element . The fle will contain order inFormation For an arbitrary number oFproducts. You can assume that you do not have more than 100 orders in the fle. Next are the name oFthe product, the number oF units, and the unit cost. ³or discounted orders, the fnal value is discount. ³orbulk order, the fnal value is the minimum size. As orders are read in,SalesOrderobjects oF theappropriate type should be created and they should be stored in one array. You may also assume that thedata in the fle will be Formatted correctly. You should not making any assumption about the ordering inthat fle.

Attachments:

Answers

(11)
Status NEW Posted 25 May 2017 03:05 AM My Price 9.00

-----------

Attachments

file 1495681683-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)