Question: I am trying to get my if-else statement to work within my program so that if i enter a negative value, it tells the user

I am trying to get my if-else statement to work within my program so that if i enter a negative value, it tells the user to input a a positive value. My program ran perfectly until adding lines 30 through 40 with that condition statement
I am trying to get my if-else statement to work within my
program so that if i enter a negative value, it tells the
user to input a a positive value. My program ran perfectly until

javati dveh stwold win (Strinellare System.out.print their inter instinct Imbert init() System.out that is the thirt) Inc frutto notice System.out. there ar e 1 1 20 este trat Y 2 > ottweit Systerican Youth Calling the System.outritie Marche ) O G aalala $ 96 & 7 00 6 9 o 5 ER T P o Documents NetBeansProjects Student semanava GRASP CSD (wa) ing Tools Window Help , 1 import java.util.Scanners 2 3 4 public class AverageNumber 5 6 public static void main(Strinel) ares) 7 8 Scanner input-new Scanner(System.in); System.out.println("What is the first number : 10 int number = input.nextInt(): 11 System.out.println("What is the second number ) 12 int number = input.nextInt(); 13 System.out.println("What is the third number ) int number input.nextInt(): 15 input.close(); 16 System.out.print("The average of these three numbers is 17 Goodbye(); 18 19 20 public static int averace(int X. Inty, int ) 21 22 return (X+Y+) / 3 23 1 24 25 public static void Goodbye 26 System.out.println("Thank You for calculating the Average 27 System.out.println("Have a nice Day") 29 Numbeck value, valo 2. W + average (number, numbers, number); (value (0) 14 System.out.println("You have entered negative value, please enter a positive value"> 3 At (value) 36 17 System.out.println("You have entered a native value, please enter positive valut"); 30 AD > (wuel (0) DcumentsNetilen Projects Studenten GRASP ESO Ovaj Tools Window Help 18 19 20 21 public static int average(int X, int Y, int 2 return (X.Y.2) /3; ) public static void Goodbye System.out.println("Thank You for Calculating the Average); System.out.printin("Have a Nice Day"); } 23 24 25 26 27 28 29 30 31 32 23 34 35 36 217 POTO Whercheck valuel, value Value 3 if (value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!