Saved Bookmarks
| 1. |
write a statement that uses a conditional operator to store in discount 10% of sale if sale is more than 5000 otherwise store in discount 5% of sale |
|
Answer» Ternary Operator: variable x = (expression) ? value if TRUE: value if false int b,c;SCANNER ob=new Scanner(System.in); System.out.println("Enter the marked PRICE");int MP=ob.nextInt();c=(MP>5000)?MP-(MP*10)100:MP-(MP*5)/100;System.out.println(c); |
|