how to check if a value inside an array is larger than a certain value

anjula serasinghe

alright so my question is probably stupid and I don't even know if it can be done but I have inserted some elements into an array through scanner, and I have put it through a certain calculation . The calculation results are also stored inside another array. what I want to do is to see if these calculated values are larger than 0. I want these calculated values to be printed along side the + or - sign. so what I was thinking is to have 2 sets of printing statements where if the sign value of the calculated amount is >0 it will proceed a print statement where as if it is <0 it will proceed another print statement. But I don't know how to check if a element inside array is larger or smaller than zero. Spare my explanation I tried my best to not make it hard to understand.

so lets say the user inputs 14. which would then go through the calculation process and store 2 inside the array.[(14-10)/2]. so since this is bigger than zero , i want a print statement to execute in a way that i can get +2 as the answer.

assume the user enters 8. which would go through the calculation process and store -2[(8-10)/2], and since -2 is stored here it is <0 and there for i want a separate statement to get executed.

My issue is i dont know how to check if a element inside an array is 0 or not. there are 5 elements inside the array and i want to check if all of them are above or below zero and print different statements for each. thank you so much in advance.I am using java btw.

    int[] bonus=new int[6]; // this is used to store the keyboard entries

    if(bonus[]<0) {       //used this to check the condition and if the conditon            
    System.out.println(level);
    System.out.println("your str=" + bonus[0]); 

   else{System.out.println("your str=+" +bonus[0]);
       }

bonus is the arrayName i have used and 0 is the first slot in which the value entered through keyboard for str is stored after the calculation process.Note:there are few coding prior to that including the array executions which i have not stated hoping this would be enough

anjula serasinghe

I managed to get through this using a for loop i and iterating through it i managed to check if they were 0 and/or above .Thank you for those who read and tried to go through this

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to replace only the first n elements in a numpy array that are larger than a certain value?

From Dev

How to find if any array elements are larger than a certain value using `arrayfun`

From Dev

How to check if an array in an arraylist contains a certain value?

From Dev

IOS how to check the value of an array if it contains a certain value and display it out

From Dev

Scatterplots: How do you select data larger or less than a certain value in R

From Dev

Check if a value is less than any value of an array

From Dev

Check if a value is less than any value of an array

From Dev

Check if partial value is inside array

From Java

How do I check in JavaScript if a value exists at a certain array index?

From Dev

check if hashmap contains value other than certain value

From Dev

check if hashmap contains value other than certain value

From Dev

how to check an array if each following value is greater than the last

From Dev

How to check for a value in an array

From Dev

How to match letters and check that value is present inside array or not using PHP

From Dev

Check if certain value exists in array of hash map

From Dev

Check if certain value exists in array of hash map

From Dev

Check if array key equals certain value JavaScript

From Dev

check if is in array a value bigger than zero

From Dev

Check if an array has different value than zero

From Dev

Check Javascript array to see if value begins with certain value

From Dev

Check if there are values other than a certain value exists in a list

From Dev

$.inArray() : check if array value has "+" inside

From Dev

$.inArray() : check if array value has "+" inside

From Dev

Is it an array inside another array or are we looking for a certain value in the array?

From Dev

How to Retrieve a Specific value from a Specific List inside a Larger List?

From Dev

How to check "i" in for loop reaches a certain value

From Dev

How to check if items with a certain value are part of a SelectList?

From Dev

Check in an array in java if value is lower than previous value and split it

From Dev

How to check the value is present inside an array and insert the value into database using PHP

Related Related

  1. 1

    How to replace only the first n elements in a numpy array that are larger than a certain value?

  2. 2

    How to find if any array elements are larger than a certain value using `arrayfun`

  3. 3

    How to check if an array in an arraylist contains a certain value?

  4. 4

    IOS how to check the value of an array if it contains a certain value and display it out

  5. 5

    Scatterplots: How do you select data larger or less than a certain value in R

  6. 6

    Check if a value is less than any value of an array

  7. 7

    Check if a value is less than any value of an array

  8. 8

    Check if partial value is inside array

  9. 9

    How do I check in JavaScript if a value exists at a certain array index?

  10. 10

    check if hashmap contains value other than certain value

  11. 11

    check if hashmap contains value other than certain value

  12. 12

    how to check an array if each following value is greater than the last

  13. 13

    How to check for a value in an array

  14. 14

    How to match letters and check that value is present inside array or not using PHP

  15. 15

    Check if certain value exists in array of hash map

  16. 16

    Check if certain value exists in array of hash map

  17. 17

    Check if array key equals certain value JavaScript

  18. 18

    check if is in array a value bigger than zero

  19. 19

    Check if an array has different value than zero

  20. 20

    Check Javascript array to see if value begins with certain value

  21. 21

    Check if there are values other than a certain value exists in a list

  22. 22

    $.inArray() : check if array value has "+" inside

  23. 23

    $.inArray() : check if array value has "+" inside

  24. 24

    Is it an array inside another array or are we looking for a certain value in the array?

  25. 25

    How to Retrieve a Specific value from a Specific List inside a Larger List?

  26. 26

    How to check "i" in for loop reaches a certain value

  27. 27

    How to check if items with a certain value are part of a SelectList?

  28. 28

    Check in an array in java if value is lower than previous value and split it

  29. 29

    How to check the value is present inside an array and insert the value into database using PHP

HotTag

Archive