# Given the following code, what will be the value of finalamount when it is displayed?

203 views

## Problem:

I am new in programming and when running below code getting some unexpected error, can anyone help me with right result after running this code?
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 int getOrderAmount()
{
return orderAmount;
}
public int getOrderDisc()
{
return orderDisc;
}
}

public class CustomerOrder
{
public static void main(String[] args)
{
int ordNum = 1234;
double ordAmount = 580.00;
double discountPer = .1;
Order order;
double finalAmount = order.getOrderAmount() —
order.getOrderAmount() * order.getOrderDisc();
System.out.println("Final order amount = \$" +
finalAmount);
}
}``````

## Solution:

I have run this code and notice what issue you are facing is that
There is no value because the object order has not been created.

## Related questions

155 views
Problems: What will be the value of x after the following code is executed? int x, y = 4, z = 6; x = (y++) * (++z); A) 24 B) 28 C) 30 D) 35 I am new to programming , Can anyone help me ?
97 views
Problem: What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; } A) 90 B) 110 C) 210 D) This is an infinite loop.
40 views
Problems: I am new to programming, I need help, can anyone help me? What would be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 1250; char cust = 'N'; if (purchase > 1000) if (cust == 'Y') discountRate = .05; else ... (cust == 'Y') discountRate = .04; else discountRate = .03; else discountRate = 0; a) .04 b) .03 c) .05 d) 0
45 views
179 views
Problem: I am finding code and not able to used right code so that I can get right output, can anyone tell the right code? Rearrange the code so that it forms a correct program that prints out the letter q:?
78 views
Problem: I am little bit confused and need help regarding my query? Which of the following expressions will determine whether x is less than or equal to y? A) x > y B) x =< y C) x <= y D) x >= y