150k views
0 votes
Given the following code, what will be the value of finalAmount when it is displayed? public class Order { private int orderNum; private double orderAmount; private double orderDiscount; public Order(int orderNumber, double orderAmt, double orderDisc) { orderNum = orderNumber; orderAmount = orderAmt; orderDiscount = orderDisc; } public double finalOrderTotal() { return orderAmount - orderAmount * orderDiscount; } } public class CustomerOrder { public static void main(String[] args) { Order order; int orderNumber = 1234; double orderAmt = 580.00; double orderDisc = .1; order = new Order(orderNumber, orderAmt, orderDisc); double finalAmount = order.finalOrderTotal(); System.out.printf("Final order amount = $%,.2f\\", finalAmount); } } Group of answer choices

1 Answer

5 votes

Answer:

$522.00

Step-by-step explanation:

  • The code in Java implements two classes Order and CustomerOrder
  • The Order class contains the method for the member variables orderNum, orderAmount and orderDiscounts, It also contains the method finalOrderTotal() for calculating the final order amount
  • The second class CustomerOrder contains the main method and serves as the driver class.
  • The finalAmount is calculated in the method finalOrderTotal() and the logic here substracting the discount from the orderAmount that is orderAmount - (orderAmount * orderDiscount)
  • Since the orderAmount in the given example is 580 and the discount is 0.1 (i.e 58) the finalAmount will be 580 - 58 which gives 522 dollars
User Solomon Suraj
by
5.8k points