Question

Could anyone please explain me this? or can you write this other way? Thank you public...

Could anyone please explain me this? or can you write this other way? Thank you

public double getTotal() {

return (item1==null?0:item1.getPrice())+

(item2==null?0:item2.getPrice())+

(item3==null?0:item3.getPrice());

0 0
Add a comment Improve this question Transcribed image text
Answer #1

It's a recursive function their are three different ternary operator statement . In , First statement if the value of item is equal to null then value return is zero otherwise it call get price function . These all three statement execute in same way. These all statement execute in using diff. Diff. Stack. And the end of function they all return value. Which is add and return by function.

Add a comment
Know the answer?
Add Answer to:
Could anyone please explain me this? or can you write this other way? Thank you public...
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
  • can anyone please explain me this question step by step, thank you sir/miss 1. Please write...

    can anyone please explain me this question step by step, thank you sir/miss 1. Please write the equilibrium expression for these reactions: a. CuSO),501,00)-000,00) Suome) b. 146) 162m) 2. For the reaction 10.00-2N06) AH = $k] Where the shift direction (right/left) will be, if: a. We add more NO2(e) b. We increase the container volume C. We decrease the temperature

  • if anyone could explain this to me on the simplest way possible it will be greatly...

    if anyone could explain this to me on the simplest way possible it will be greatly appreciated: what is the voltage between two points on an equipotential line? will this voltage cause a charge to move along the line?

  • write the following code in java thank you and if you can, could you please write...

    write the following code in java thank you and if you can, could you please write the code in replit and sent me a link to it replit is basically like a online compiler and you can write java code on it thank you The first part is to implement one of the questions from your examination. /* A Range objects represents an integer range, such as 1-10 or 50701-50799. The lower and upper bounds of a Range are given...

  • Could anyone please help me with these and show drawing if possible? Thank you so much!...

    Could anyone please help me with these and show drawing if possible? Thank you so much! Draw the structure for benzoic acid. Draw the equilibrium reaction between benzoic acid and water. Label the acid, base, conjugate acid, and conjugate base.

  • Could you please help me with an answer to this question in a simple way for...

    Could you please help me with an answer to this question in a simple way for the beginner? This is a beginner level class so can you please help me. The code must have beginner level implementation. Can you also please explain what things do. Thank you! Write a program that prompts the user for a positive integer number smaller than 256 (i.e. in [0...255]) and converts it into an 8-bit binary number. The bits are the remainders of the...

  • Can you please give me an answer asap. Thank you. Can you please just explain what...

    Can you please give me an answer asap. Thank you. Can you please just explain what the method does and provide a recurrence relation for the method. And State the method's runtime in big-Oh notation of following. Question no 2) //This is an instance method for MyLinkedList from project 1. //For writing the recurrence relation, n is size - index of node. 1/Precondition: node is an element of the list public void problem2 (MyListNode<E> node) { if(node.getNext() != null){ problem2...

  • Please help Thank you Can anyone please help me compare the fiscal policy between Venezuela with...

    Please help Thank you Can anyone please help me compare the fiscal policy between Venezuela with South Africa, Spain, and Turkey. Please highlight the key characteristics Thank you so much

  • Can anyone help me with these, please? Thank you! Examine a trendy, fad, or other Weight...

    Can anyone help me with these, please? Thank you! Examine a trendy, fad, or other Weight Loss diet that you have heard about/read about/talked about/tried. (Examples include the Atkins, South Beach, Grapefruit Diet, ketogenic diet, cabbage soup diet, etc.) Answer the following questions and submit in class, typewritten, double spaced. No word limit on this, but see breakdown of points per question so make sure answer questions fully. Use any 3 sources; sources do not have to be reputable as...

  • can you please explain this answer to me in the simplest way possible and why that...

    can you please explain this answer to me in the simplest way possible and why that is the answer thank you! 61. Which set of quantum numbers cannot specify an orbital? a. n = 2,1 = 1, m, = -1 b. n = 3,1 = 2, m = 0 c. n = 3,1 = 3, mi = 2 d. n = 4,1 = 3, m = 0

  • Could anyone help? Thank you. B.6 - 10 pts string* callMe(string& s) { s = "Senorita";...

    Could anyone help? Thank you. B.6 - 10 pts string* callMe(string& s) { s = "Senorita"; return &s; int main() { string s = "Senor"; string* str = callme(s); cout << "Call me ""+ *str + "\""; return; What is the output or the error of this program? And please explain the data flow in detail (to memory level).

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