+ 1
what is something wrong with my coding? can u check why i cant get the max and min
3 odpowiedzi
+ 1
thanks a lot. but can you tell me how can i get the min. im confused
0
sales[i]= sc.nextDouble()
By this you are taking only one input..
So input stored in sales[0], i=0,
Remaining i=1,2,3 sales[i] assigned to 0.
if(total_sales<total_sales){ //this condition never comes true.. Since both equal, like a<a =>false
Are you missing any, may be typing mistake...
So this if, won't executes.....
Hoping it helps you...
0
If you need any further help, about this.,
Najwa Mohammad
You're Wel come..
edit:
am I missed to read the reply ?
anyways , to complete answer :
for minnimum =>
first, you need take all inputs then assign min=size[0]
then do calculations.. like :
for(i=0; i<sales.length;i++)
sales[i]= sc.nextDouble();
min = sales[0];
for(i=0; i<sales.length;i++){
..
..
}
otherwise, if you can with your approach by assiging min= integer max value like :
double min= Integer.MAX_VALUE;
and check condition like :
if(total_sales<min){
min=total_sales;.
Hope it helps...