L := [39.68, 5.697, .9057E-3, .5612E-2, 30.75, .1005E-3, 10.29, .2387E-1, .3347E
ID: 3530054 • Letter: L
Question
L := [39.68, 5.697, .9057E-3, .5612E-2, 30.75, .1005E-3, 10.29, .2387E-1, .3347E-3, .9724E-1, 7.536, 8.207, 85.10, .2001, .4738, .2983E-2, .6860E-3, .4666E-1, 3.164, 63.59, .1311E-3, 2.915, 8.612, .3868E-2, .8995E-3, 8.487, .6143, .9891, .5100, 7.161, .8825, .7505E-3, .2372E-1, .3440E-3, 5.783, .4258E-3, .9256E-1, 60.52, .9271, 9.111, .3885E-2, 2.929, 3.494, 36.90, .8834E-2, .4789E-3, 74.42, .9165E-1, .2045, .3710E-2, .2585]; We want two counts: d1, the count of items 0.02_< Li and Li< 0.0032, and d2, the count of items 0.055_<, Li_<0.079 . The ranges for the counts do not overlap. Write a script to find d1 and d2. Enter the list of two integers [d1, d2]. For example, if the count for d1 is 5, and the count for d2 is 47, then enter the list [5,47].Explanation / Answer
Hey man..Check out those values non of them are lies between 0.055 to 0.079
And in prwevious post i have done a mistek.so i wroteif(0.02 <= l && l <= 0.0032) but acutally it should be
if(0.0032 <= l && l <= 0.02) the reverse of that previous line.I have corrected that answer.and also got output 5 for d1 but for d2 still no result..Please check the intervale for which you are counting d2.If u found any different interval then replace it in line .
else if(0.055 <= l && l <=0.079)
.I have done i what i can do..If i helped you then rate..
The updated Code
public class test2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stu
double[] L = {39.68, 5.697, .9057E-3, .5612E-2, 30.75,.1005E-3, 10.29, .2387E-1, .3347E-3, .9724E-1, 7.536, 8.207, 85.10, .2001, .4738, .2983E-2, .6860E-3, .4666E-1, 3.164, 63.59, .1311E-3, 2.915, 8.612, .3868E-2, .8995E-3, 8.487, .6143, .9891, .5100, 7.161, .8825, .7505E-3, .2372E-1, .3440E-3, 5.783, .4258E-3, .9256E-1, 60.52, .9271, 9.111, .3885E-2, 2.929, 3.494, 36.90, .8834E-2, .4789E-3, 74.42, .9165E-1, .2045, .3710E-2, .2585};
int d1=0;
int d2=0;
int[] count=new int[2];
for(Double l: L)
{
if(0.0032 <= l && l <= 0.02)
{
d1++;
}
else if(0.055 <= l && l <=0.079)
{
d2++;
}
}
count[0]=d1;
count[1]=d2;
System.out.println("no of value between 0.0032<= l && l<= 0.02 is :"+count[0]);
System.out.println("no of value between 0.055<= l && l <=0.079 is :"+count[1]);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.