Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

// setprice per item public void setPricePerItem ( double price ) { pricePerItem

ID: 3609645 • Letter: #

Question

// setprice per item
public
void setPricePerItem( double price )
{
     pricePerItem
= ( price <0.0) ? 0.0 :price; //validate price
} // endmethod setPricePerItem

Based off this post: computer-science-topic-5-504359-cpi0.aspx

      The code above does not make senseto me. It seems like backwards thinking because to me it says ifthe price is less than zero set pricePerItem equal to price else ifprice is greater than zero, price is set to zero and pricePerItemis equal to price. Is my thinking wrong?

Explanation / Answer

please rate - thanks // setprice per item public void setPricePerItem( double price ){      pricePerItem = ( price