Question

Hi, please read the entire problem. I need help with the BusOrder class and test for...

Hi, please read the entire problem.

I need help with the BusOrder class and test for it.

In Java you will require the use of loops and decisions for the following scenario:

Pretty Vehicles (PV) is a vehicle company that makes four different types of vehicles: cars, buses, motorcycles, and vans.

Their management team got together and decided that you start working on a more serious software for their most profitable vehicles first - Cars and Busses.

Your job now is to build the order classes for the two vehicle types, document them with Javadoc and write test classes for both classes you create.

BusOrder

As stated in the CarOrder requirements, the payment process is different for different vehicles. The main difference is that usually busses are bought by cities/companies in bulk, and cars are mostly bought in a one-car-per-customer fashion. The benefit of buying in bulk is that the buyer gets a discount on the total price of the busses they buy, and the more busses they buy, the bigger the discount.

Also, cities, counties and other government bodies usually get an extra discount on top of the first bulk discounted price.

For the calculations to be made, we first need an invoice, or an order. The order method, which is the constructor in our case (described in detail below), will set some variables in the instance of the BusOrder object, such as quantity, buyer, whether they are a government buyer or not, etc.. It will also call some methods to set some variables based on calculations made for the discount percentage and price per bus.

Once a bus order is made, Pretty Vehicles wants to be able to print a schedule as to when the busses are going to be built and finished, and how many per month they are going to build. The way they decide the schedule is based on how many vehicles the buyer is buying. A buyer that buys more vehicles is going to have more priority, and by that we mean more buses per month will be built for them.

With all that in mind, here are the requirements your manager compiled:

  • Variables
    • quantity
    • model
    • model year
    • buyerName
    • governmentBody (boolean)
    • loanLengthYears
    • discountPercent
    • pricePerBus
  • Methods
    • getters and setters for all the variables mentioned above.
    • A constructor (quantity, model, year, buyerName, governmentBody, loanLengthYears);
      • When the constructor is initiated, apart from setting the variables' values, it should call a method calculateDiscountPercent() - described next, and a calculatePricePerBus() method - described below. If the model name is not one of the model names mentioned below, print a message saying "This model does not exist"
    • calculateDiscountPercent() : this method will calculate the discount percent and set the discountPercent variable in the class instance. The discount is calculated this way:
      • If a government body, an initial 5% discount automatically applies, if not, no initial discount is applied
      • If the model year of the busses in the order is less than 2016, then a 3% discount is added to the current discount percentage sum, else - no discount is added to the percentage sum
      • Based on the quantity
        • If less than 10 buses are ordered, no quantity discount is applied
        • if the quantity is between 10 and 50, a 5% discount is added to the current discount percentage sum
        • if the quantity is greater than 50, then a 10% discount is added to the current discount percentage sum
    • calculatePricePerBus() : this method calculates the price per bus for the order based on the model year and the model name. The following are the prices of the busses per model year bracket.
      • Model "Mad Max"
        • Model year 2016 - 2019 -> $80,000
        • Model year 2013 - 2015 -> $60,000
        • Model year 2010 - 2012 -> $45,000
      • Model "Low Emission"
        • Model year 2016 - 2019 -> $95,000
        • Model year 2013 - 2015 -> $80,000
        • Model year 2010 - 2012 -> $65,000
      • Model "No Oil"
        • Model year 2016 - 2019 -> $110,000
        • Model year 2013 - 2015 -> $95,000
        • Model year 2010 - 2012 -> $80,000
  • Additional Methods
    • printBuildingSchedule() : this method will print the building schedule for each month of the building process. As briefly mentioned above, the schedule is based on the quantity of busses ordered. The rules are the following:
      • If less than 10 busses are ordered, PV builds them with a regular schedule, and that is 4 per month.
      • If 10 - 50 busses are ordered, PV builds 6 busses per month, or one bus every 5 days.
      • If more than 50 busses are ordered, PV builds 8 busses per month, or 2 busses per week.

        Based on that, you should build this method so that it prints the number of busses for each month. For example, if 7 busses are ordered:

        Month 1 - 4 buses
        Month 2 - 3 buses
    • printPaymentSchedule() : this method will print the payment schedule. First, it will calculate the total price that needs to be paid, that is: quantity x pricePerBus x discountPercent. After that number is found, the interest amount needs to be calculated. PV's rule is that government bodies don't pay interest (0%), but private companies need to pay 1% interest. Use the formula described here (https://www.thebalance.com/calculate-loan-interest-315532). Interest = Principal x rate x time to calculate the interest amount. Once you have a final number, print the payment for each month . Example:

    • Month 1 : $599
      Month 2 : $599

      The value is going to be repetitive, but usually companies want to have the month to month breakdown so that they can use it for their budget planning.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code with sample output


public class Order {
   int quantity;
   String model;
   int modelYear;
   String buyerName;
   boolean governmentBody;
   int loanLengthYears;
   double discountPercent;
   double pricePerBus;
   public int getQuantity() {
       return quantity;
   }
   public void setQuantity(int quantity) {
       this.quantity = quantity;
   }
   public String getModel() {
       return model;
   }
   public void setModel(String model) {
       this.model = model;
   }
   public int getModelYear() {
       return modelYear;
   }
   public void setModelYear(int modelYear) {
       this.modelYear = modelYear;
   }
   public String getBuyerName() {
       return buyerName;
   }
   public void setBuyerName(String buyerName) {
       this.buyerName = buyerName;
   }
   public boolean isGovernmentBody() {
       return governmentBody;
   }
   public void setGovernmentBody(boolean governmentBody) {
       this.governmentBody = governmentBody;
   }
   public int getLoanLengthYears() {
       return loanLengthYears;
   }
   public void setLoanLengthYears(int loanLengthYears) {
       this.loanLengthYears = loanLengthYears;
   }
   public Order(int quantity, String model, int modelYear, String buyerName, boolean governmentBody,
           int loanLengthYears) {
       super();
       this.quantity = quantity;
       this.model = model;
       this.modelYear = modelYear;
       this.buyerName = buyerName;
       this.governmentBody = governmentBody;
       this.loanLengthYears = loanLengthYears;
       this.calculateDiscountPercent();
       this.calculatePricePerBus();
   }
   void calculateDiscountPercent(){
       double discount=0;
       if(this.governmentBody == true)
           discount =5;
       if(this.modelYear <2016)
           discount+=3;
       if(this.quantity>=10 && this.quantity <=50)
           discount+=5;
       else if(this.quantity>50)
           discount +=10;
       this.setDiscountPercent(discount/100);
   }
   void calculatePricePerBus(){
       if(this.model.equals("Mad Max")){
           if(this.modelYear>=2016 && this.modelYear<=2019 )
               this.setPricePerBus(80000);
           else if(this.modelYear>=2013 && this.modelYear<=2015 )
               this.setPricePerBus(60000);
           else if(this.modelYear>=2010 && this.modelYear<=2012 )
               this.setPricePerBus(45000);
       }
       else if(this.model.equals("Low Emission")){
           if(this.modelYear>=2016 && this.modelYear<=2019 )
               this.setPricePerBus(95000);
           else if(this.modelYear>=2013 && this.modelYear<=2015 )
               this.setPricePerBus(80000);
           else if(this.modelYear>=2010 && this.modelYear<=2012 )
               this.setPricePerBus(65000);
       }
       else if(this.model.equals("No oil")){
          
               if(this.modelYear>=2016 && this.modelYear<=2019 )
                   this.setPricePerBus(110000);
               else if(this.modelYear>=2013 && this.modelYear<=2015 )
                   this.setPricePerBus(95000);
               else if(this.modelYear>=2010 && this.modelYear<=2012 )
                   this.setPricePerBus(80000);
       }
           else
               System.out.println("Model does mot exist");
   }
  
   public double getDiscountPercent() {
       return discountPercent;
   }
   public void setDiscountPercent(double discountPercent) {
       this.discountPercent = discountPercent;
   }
   public double getPricePerBus() {
       return pricePerBus;
   }
   public void setPricePerBus(double pricePerBus) {
       this.pricePerBus = pricePerBus;
   }
  
   void printBuildingSchedule(){
       //check how many buses a month
       int perMonth=0;
       if(this.quantity<10)
           perMonth = 4;
       else if(this.quantity>=10 && this.quantity <=50)
           perMonth = 6;
       else if(this.quantity>50)
           perMonth = 8;
       int qty = this.quantity;
       //logic for display keep looping if qty becomes less than permonth it's the last iteration
       int i=1;
       while(true){
           System.out.println("Month "+i+ "-"+perMonth +" buses");
           qty -=perMonth;
           i++;
           if(qty<=perMonth){
               System.out.println("Month "+i+ "-"+qty +" buses");break;}
       }
      
   }
   void printPaymentSchedule(){
       double total = this.quantity * pricePerBus * discountPercent;
       double interest;
       int perMonth=0;
       if(this.governmentBody==true)
           interest =0;
       else
           interest = total * 0.01 * this.loanLengthYears;
//System.out.println(this.discountPercent+ " "+this.pricePerBus);
       if(this.quantity<10)
           perMonth = 4;
       else if(this.quantity>=10 && this.quantity <=50)
           perMonth = 6;
       else if(this.quantity>50)
           perMonth = 8;
       int qty=this.quantity;
       int i=1;
       while(true){
           System.out.println("Month "+i+ "- $"+interest);
           qty -=perMonth;
           i++;
           if(qty<=perMonth){
               System.out.println("Month "+i+ "- $"+interest);break;}
       }
   }
   public static void main(String[] args){
       Order ord = new Order(25, "Low Emission",
2013, "Lucy", false,
               23);
       ord.printBuildingSchedule();
       ord.printPaymentSchedule();
   }
}

Output

Add a comment
Know the answer?
Add Answer to:
Hi, please read the entire problem. I need help with the BusOrder class and test for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 6-1 Test and debug the Invoice Application i need help with this please.. all help is...

    6-1 Test and debug the Invoice Application i need help with this please.. all help is appreciated Source code Java: import java.util.Scanner; import java.text.NumberFormat; public class InvoiceApp { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String choice = "y"; while (!choice.equalsIgnoreCase("n")) { // get the input from the user System.out.print("Enter customer type (r/c): "); String customerType = sc.next(); System.out.print("Enter subtotal: "); double subtotal = sc.nextDouble(); // get the discount percent double discountPercent = 0.0; switch(customerType) {...

  • i need help working out the problem and entering it into excel Background: On January 1,...

    i need help working out the problem and entering it into excel Background: On January 1, 2020, the company has purchased a 14 year $100,000 bonds investment. The bond calls for an annual payment of interest on 12/31 at a contractual (stated) rate of 6%. Given the credit standing of the issuing company, an interest rate of 8.25% has been imputed as the effective rate. The principal amount of the bond is due at maturity. The company classified this bond...

  • Hi there, I have problem-solving this question, would definitely need help to explain if we need ...

    Hi there, I have problem-solving this question, would definitely need help to explain if we need to look for the taxable income portion: Question: Topless:- A sporty convertible with a cost of $100,000 and a useful life of 5 years. It will produce rental income of $60,000 per year and operating costs of $10,000 per year. A major service is required after 3 years costing $15,000. A salvage value of $25,000 is expected after 5 Years. The required return is...

  • ** Please read the bold statement after the question, I have the answers, but I need...

    ** Please read the bold statement after the question, I have the answers, but I need to make sure they are correct. Thanks** #1 Using a spreadsheet application, create an amortization schedule for a 30 year, fixed rate (4.58%) $200k loan. Answer the following: what is the monthly payment? how much total interest will you pay? Print out enough of your spreadsheet to defend your work and answers. Assume that you took the loan in #1 and paid your monthly...

  • TEST, I need Help A.S.A.P PLease!!! I need to submit this within the next hour and a half. It's...

    1. Regression is always a superior forecasting method to exponential smoothing, so regression should be used whenever the appropriate software is available. (Points :1)TrueFalse2. Time-series models rely on judgment in an attempt to incorporate qualitative or subjective factors into the forecasting model. (Points : 1)TrueFalse3. A trend-projection forecasting method is a causal forecasting method. (Points : 1)TrueFalse4. Qualitative models attempt to incorporate judgmental or subjective factors into the forecasting model. (Points : 1)TrueFalse5. The naive forecast for the next period...

  • hi..please help..so i took a test and i got all of it wrong and im not...

    hi..please help..so i took a test and i got all of it wrong and im not sure how to do this problems..this is Investment class..please explain every step because im going to study using this material.thank you Fall 2010 4. Compare and contrast open end ve closed-end mutual funds will sell as long you want to buy the share, management comparin thom to you, while closed end mutual funds Preferred stocks on any public traced securities such as cquity, bond...

  • I need help on question 2. MODULE IV: TIME VALUE OF MONEY INTRODUCTION The time value...

    I need help on question 2. MODULE IV: TIME VALUE OF MONEY INTRODUCTION The time value of money analysis has many a lysis has many applications, ranging from setting hedules for paying off loans to decisions about whether to invest in a partie financial instrument. First, let's define the following notations: I = the interest rate per period Na the total number of payment periods in an annuity PMT = the annuity payment made each period PV = present value...

  • I need help recording the following adjusting entries in the General Journal. Adjusting journal Entries. Adj-1...

    I need help recording the following adjusting entries in the General Journal. Adjusting journal Entries. Adj-1 Dec. 31 The company has $1,800 of supplies left at month end. Adj-2 Dec. 31 Record the portion of the Prepaid Insurance used in December. Adj-3 Dec. 31 Record one month of depreciation for the building purchased on December 1st. Adj-4 Dec. 31 Employees earned $1,200 in salaries the last week in December that will be paid on January 10th of next year. Adj-5...

  • please help me answer these questions, I provided all the information. thank you You are the...

    please help me answer these questions, I provided all the information. thank you You are the financial analyst of the Management and Budgeting Oftice (MBO) for the Procurement Agency of your Municipality The Transport system of your city needs to have an extension/renovation of the existing equipment (eg vehicles, on-board Wi-Fi network, etc.) and infrastructure (e.g. binary for bus, etc). The transport system is totally owned by the municipality, hence it is in charge of investment decision and business activity...

  • NEED HELP WITH THIS PROBLEMS!!!! There all together please read the information! Comprehensive Problem 3 Part...

    NEED HELP WITH THIS PROBLEMS!!!! There all together please read the information! Comprehensive Problem 3 Part 4: Note: You must complete parts 1, 2, and 3 before completing part 4 of this comprehensive problem. Based on the following selected data, journalize the adjusting entries as of December 31 of the current year. If no entry is required, select "No entry required" from the dropdown and leave the amount boxes blank. If an amount box does not require an entry, leave...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT