The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
I need the answers by 11:59 pm tonight , you find the questions in the attachments
Â
|
Annual Report          |
|
Computer Programming-I CS140 |
Â
Â
|
Instructions: |
|
·      This Assignment must be submitted on Blackboard via the allocated folder. ·      Email submission will not be accepted. ·      You are advised to make your work clear and well-presented, marks may be reduced for poor presentation. ·      You MUST show all your work. ·      Late submission will result in ZERO marks being awarded. ·      Identical copy from students or other resources will result in ZERO marks for all involved students. ·       |
|
   Â
 |
 (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 |
|
      |
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 |
|
      |
Â
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 |
|
      |
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
…
Â
Â
Â
----------- Â ----------- 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