Ask your own question, for FREE!
Computer Science 12 Online
MadamMystery:

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); } }

TETSXPREME:

What do you think it is?

MadamMystery:

@tetsxpreme wrote:
What do you think it is?
It's a Java program -_-

TETSXPREME:

Ik but you can still have your thoughts on it

MadamMystery:

@tetsxpreme wrote:
Ik but you can still have your thoughts on it
But I am the questioner only

axie:

@extrinix < hes offline but he knows code more than anyone I know

Vocaloid:

@smokeybrown

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

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!