SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 209 Weeks Ago, 4 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Communications Posted 16 Dec 2017 My Price 8.00

many times does the code snippet given below display

Question One

 

(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);

 

 

 

1 Marks 




Question Two

a.        What is the output of the following snipped code?

public class Test {

  public static void main(String args[]) {

     int x = 45;

     int y = 10;

     if( x == 30 ) {

        if( y == 10 ) {

           System.out.print("X = 30 and Y = 10");

        else

           System.out.print("X = 45 and Y = 10");

        }

      }

      System.out.print("Nested If");

  }

}

 

 

 

 

 

 

 

 

b.        If the user enter 2000, what is the output of the code segment shown below?

public class Leapyear{

  public static void main(String[] args)  {

     int year;   

     Scanner console = new Scanner(System.in);

     System.out.print("Enter a year : ");

     year = console.nextInt();

     if (year % 4 == 0)     {

        if (year % 100 == 0) {

           if (year % 400 == 0) {

              System.out.println("A leap year");

           }

           else           {

              System.out.println("Not a leap year");

           }

        }

        else        {

           System.out.println("A leap year");

        }

     }

     else     {

        System.out.println("Not a leap year");

     }  } }

 

 

 

0.5 Marks 




Question Three

What is the output of:

 

for (int i=1; i <= 5; i++)

             {

                     for (int j=1; j <= 5; j++)

                            System.out.print (i*j + " ");

                     System.out.println();

             }

 

 

 

 

 

 

 

1.5 Marks 




Question Four

Write a program that asks the user to enter a number between 1 and 10 then prints the related multiplication table. The program must ask the user if he wants to continue by choosing another number or quit.

NB: you have to run your program then join a screenshot of the execution to your answer file

Typical run of the program:

Give your proposed number between 1 and 10: 4

The Multiplication Table of 4 is

1 * 4 = 4

2 * 4 = 8

3 * 4 = 12

4 * 4 = 16

5 * 4 = 20

6 * 4 = 24

7 * 4 = 28

8 * 4 = 32

9 * 4 = 36

10 * 4 = 40

Do you want to continue Y/N? Y

Give your proposed number between 1 and 10: 7

The Multiplication Table of 7 is

1 * 7 = 7

2 * 7 = 14

â¦

Answers

(5)
Status NEW Posted 16 Dec 2017 08:12 AM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)