Print the output of the following program:— public class discount { public static void main (int cost) { int d, amt; d=(25*cost)/100; amt=cost-discount; System.out.println("Discount="+d); System.out.println("Amount="+amt); } }
What do you think it is?
Ik but you can still have your thoughts on it
@extrinix < hes offline but he knows code more than anyone I know
@smokeybrown
The two print statements in the program are: System.out.println("Discount="+d); System.out.println("Amount="+amt); And they will print out their respective Strings, along with the value of the integer variables, d and amt respectively The value of d depends on the value of cost, specifically d is 25% of cost (rounded down because both are integers); the value of amt is equal to cost - discount. So, the printed output will depend on the value of the initial parameter cost. For example, if the cost passed to the function is equal to 100, the output will be: Discount=25 Amount=75 Another example, if the cost is equal to 14, the output will be: Discount=3 Amount=11 In short, the printed output depends on the value of cost, which is passed in as a parameter when the function is called
Join our real-time social learning platform and learn together with your friends!