• Register
0 votes


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 = $" +


7 5 3
5,380 points

Please log in or register to answer this question.

1 Answer

0 votes


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.
8 5 2
10,530 points

Related questions

0 votes
1 answer 66 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 ?
asked Feb 13, 2020 maddi86 5.4k points
0 votes
1 answer 28 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.
asked Mar 9, 2020 ArifulIslam 5.6k points
0 votes
2 answers 32 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
asked Feb 14, 2020 maddi86 5.4k points
0 votes
1 answer 48 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
asked Feb 22, 2020 maddi86 5.4k points
0 votes
1 answer 138 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:?
asked Feb 19, 2020 maddi86 5.4k points
0 votes
1 answer 415 views
The code below is based on code.activestate.com/recipes/413614/ However, the key point of the recipe - that it provides a way to break out of the iteration on an iterator if the iterator is empty - doesn't seem to work here, instead behaving ... next_choice = choice_iterator.next() except StopIteration: print "No matches. Exiting..." sys.exit() else: choice_iterator = itertools.chain([next_choi
asked Oct 28, 2020 psandprop 2.4k points
0 votes
1 answer 87 views
Problem : I want to deploy my ASP.NET application. I have tried deploying my site to IIS, but when I visit it with the browser, it gives me following error : Server Error 500 - Internal server error. There is a problem with the resource you are looking for ... error: The page cannot be displayed because an internal server error has occurred. I want to see the actual issue behind my server error?
asked Dec 7, 2019 alecxe 7.5k points
0 votes
1 answer 24 views
Problem : When I try to connect to the MySQL server from PHP, I see a below error: &ldquo;Deprecated: The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /path/to/filename.php on line 123&rdquo; The code on a referenced ... that my arguments are correct, and also exact code has been working for many years without a problem. So how can I fix my code?
asked Feb 3, 2020 jwilliam 3.9k points
0 votes
1 answer 38 views
Problem: How can we solve this problem? Is there any alternate solution?
asked Nov 19, 2020 prog_learner 2.5k points