Question

y-y+2 ; eise iflxc4) Output: else System.out.printin(y) 8. int x-5, y-3 if (xs 10) x x-2 else x-x+2; Output: System.out print
0 0
Add a comment Improve this question Transcribed image text
Answer #1

8)

// Screenshot of the code & output

Java workspace-Assignments /src/com/java/Simple.java-Eclipse DE File Edit Source Refactor RefactrNavigate Search Project Run
// code to copy


public class Simple {  
  
   public static void main(String[] args) {      
       int x=5, y=3;
       if(x>=10) {
           x=x-2;
           y=y+x;
       }
       else {
           x=x+2;
           y=y-x;
       }
       System.out.println(y);
   }
  
}

9)

// Screenshot of the code & output

File Edit Source Refactor Refactor Naviga Search Project Run Window Help Project Explorer Ju JUnit 3 publio class Simple v฿ c
// code to copy

public class Simple {  
  
   public static void main(String[] args)
   {      
       int x=8;
       while(x>0) {
           System.out.println("Hi");
           x-=3;
       }
          
   }
  
}

10)

// Screenshot of the code & output

Java Workspace- Assignments/src/comjava/Simple java - Eclipse IDE File Edit Source Refactor RefactrNavigate Search Project Ru
// code to copy

public class Simple {  
  
   public static void main(String[] args)
   {      
       int x = 5;
       do{
           x +=5;
       }while(x>23);
      
           System.out.println(x);          
          
   }
  
}

11)

// Screenshot of the code & output

Java workspace-Assignments/src/com/java/Simple.java-Eclipse DE File Edit Source Refactor Refactr Navigate Search Project Run
// code to copy

public class Simple {  
  
   public static void main(String[] args)
   {      
       int x = 25, y=8;
      
           x += y++;      
      
           System.out.println(x + " "+ y);          
          
   }
  
}

12)

// Screenshot of the code & output

Java workspace-Assignments/src/com/java/Simple.java-Eclipse DE File Edit Source Refactor Refactr Navigate Search Project Run
// code to copy

public class Simple {  
  
   public static void main(String[] args) {      
       int[] array1 = {2,4,6,8,10};
       int value = 0;
       for ( int a = 0; a < array1.length; a++) {
           value +=array1[a];
       }
       System.out.println(value);
   }
  
}

Add a comment
Know the answer?
Add Answer to:
y-y+2 ; eise iflxc4) Output: else System.out.printin(y) 8. int x-5, y-3 if (xs 10) x x-2...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • a) int a -5, b 6, c 7 System.out.printin(a--b-- System.out.printin(a---a- System.out.println (a+++b+++c) Output from part a)...

    a) int a -5, b 6, c 7 System.out.printin(a--b-- System.out.printin(a---a- System.out.println (a+++b+++c) Output from part a) int vl-10, v2 -20 if (viV2 30 11 v2+21) Output from part b) System.out.printin("1."+vi+""2) System.out.println("2. " +vl+"+ v2) System.out.printin("3."+vl+"v2)L else if (v2-20 && ++v1 11)( elset Output from part c) int x - 10, y - 20 System.out.println (x) System.out.println(y)

  • What is the output of following program: public class Test{ public static void main(String[] args) {...

    What is the output of following program: public class Test{ public static void main(String[] args) { A a = new A(): a method B(): } } class A{ public A(){ System out println("A's constructor is executed"): } public void method(){ System out printin ("methodA is executed"): } public void methodAB(){ System out printin ("As methodAB is executed"): } } class B extends A { private int num = 0: public B (){ super(): System out printin ("B's constructor is executed"):...

  • * The method fun will sum all the values except H for the multiples of 5...

    * The method fun will sum all the values except H for the multiples of 5 unless it is a multiple of 100. public static int fun (int [] mary) ( return 0 public static void main (Stringt args) //client code int[l bob - (13, 27. 45, 93, 100, 425, 300, 205) System.out printin( Arrays.toString ( bob ) System.out-printin Sum tun ( bob )a 533 System.out.printin 21 23 25 26 27 28 29 30 int[1 ted (115,1200,1350,4121, 5237. 6445, 7600)...

  • With a Scanner object created as follows, what method do you use to read an int...

    With a Scanner object created as follows, what method do you use to read an int value? Scanner input = new Scanner(System.in); A. input.int(); B. input.nextInt(); C. input.integer(); D. input.nextInteger(); What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0"); else System.out.println("x equals 0"); A. x is greater than 0 B. x is less than 0 C. x equals 0...

  • what is output public static void main(String args) Scanner keyboard new Scanner(System.in); int u 14; int...

    what is output public static void main(String args) Scanner keyboard new Scanner(System.in); int u 14; int w 0; int x; int y 5; float z = 6.1 System.out.print("Enter y: "); x keyboard.nextint); System.out.println('y'); System.out.println(x); System.out.println(w*3); x- x+(int)z; System.out.println(x); 0 System.out.println(u); System.out.,println(u); System.out.println"x In" + y); System.out.print(y + z); ) liclosing main method 1 liclosing class header

  • Question 41 Which of the following is NOT a valid assignment statement? A. x = 55;...

    Question 41 Which of the following is NOT a valid assignment statement? A. x = 55; B. 55 = x; C. x += 3; D. x = 56 + y; Question 42 What is the result of 45 / 4? A. 11.25 B. 10 C. 12 D. 11 Question 43 What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0");...

  • PLEASE SOLVE THESE QUESTIONS Q.3.6 What does the following code output? int x = 8; int...

    PLEASE SOLVE THESE QUESTIONS Q.3.6 What does the following code output? int x = 8; int y = 2; while(x > 8) { X- y+=2; } System.out.println(y); Q.3.7 What does the following code output? System.out.println((2 + 3 - 5) * (3/3) + (5+5)); Q.3.8 What does the following code output? if((2 == 2) && (3 != 3) && ((5 + 1)==6){ System.out.println(true); else { System.out.println(false);

  • 5. What is the output of the following section of a program int a[10] = {2,5,1,6,x,7,0,3,y,8};       ...

    5. What is the output of the following section of a program int a[10] = {2,5,1,6,x,7,0,3,y,8};        for(int i=0;i<9;i++)      a[i]=a[i+1]; for(int i=0;i<8;i++)      cout<<a[i]<<” “; cout<<endl; 6. What will be shown on the output screen after following statements are executed? char a[ ]="I have a part time job"; int c=x, i=0 while(a[i]!=’\0’){      if(a[i]==' '){           c++;           cout<<endl;      }      else           cout<<a[i];      i++; } cout<<c<<endl; 7. After following statements are executed, what are the outputs char a[ ]= "Fresno City College";        for (i...

  • X. (10 points) In the box provided show the output for this program segment public static...

    X. (10 points) In the box provided show the output for this program segment public static void main (String [) args) intl num-(1,2.3,4) System.out printinx+y+num12) tyit(y, x. num): System.out printin(x+ynum(2): public static void tryit(int a, int b, intl c) int x c[2]-20 System.out printin(x+bCI2) XI. (7 points) a. Write a method NEGATIVE that receives as parameters a one-dimensional array variable LIST of integers. The method should return the sum of the negative elements in the array. You may not assume...

  • (a)How many times does the code snippet given below display "Hello"? int x = 1; while...

    (a)How many times does the code snippet given below display "Hello"? int x = 1; while (x != 15) {    System.out.println ("Hello");    x++; } (b)What is the output of the following code fragment? int i = 1; int sum = 0; while (i <= 5) {    sum = sum + i;    i++; } System.out.println("The value of sum is " + sum); Quie 2 What is the output of the following snipped code? public class Test {...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT