what is something wrong with my coding? can u check why i cant get the max and min | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is something wrong with my coding? can u check why i cant get the max and min

https://code.sololearn.com/c77L1GpDqOXr/?ref=app

12th Mar 2020, 11:56 AM
Najwa Mohammad
Najwa Mohammad - avatar
3 Answers
+ 1
thanks a lot. but can you tell me how can i get the min. im confused
12th Mar 2020, 3:01 PM
Najwa Mohammad
Najwa Mohammad - avatar
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...
12th Mar 2020, 1:47 PM
Jayakrishna 🇮🇳
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...
12th Mar 2020, 3:05 PM
Jayakrishna 🇮🇳