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

Every problem below is worded exactly as we intend it to be. Do not remove any s

ID: 3630265 • Letter: E

Question

Every problem below is worded exactly as we intend it to be.
Do not remove any semicolon from any problem.
If a problem contains an infinite loop, say so.


1. The four double variables dA, dB, dC, and dD already contain given values.
Write a segment of Java code that will place into the double variable dMin
the smallest of the values in dA, dB, dC, and dD.

For example, if dA=2.4 and dB=1.7 and dC=9.6 and dD=5.8 then your code
should leave dMin = 1.7, the smallest of the four values.
Note: This is only an example. Your code must be general.
Note: The values dA, dB, dC, and dD are not guaranteed to be positive
numbers. They could all be negative. Your code must work correctly in
all cases.

Explanation / Answer

class test

{

public static void main(String[] args)

{

double dA=2.4,dB=1.7,dC=9.6,dD=5.8;

double dmin= dA;

if(dB < dmin) dmin = dB;

if(dC < dmin) dmin = dC;

if(dD < dmin) dmin = dD;

System.out.println( " The smallest value is given by " +dmin);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote