Midterm.pdf - Luv Chohan Midterm CSCI-C101/INFO-I210 Q1...

This preview shows page 1 - 3 out of 5 pages.

Luv Chohan Midterm: CSCI-C101/INFO-I210 Q1: int x = 50 // define variable while (x > 0) // x is GREATER than 0 { System.out.println(x + seconds to go ); } Q2: switch (choice) { case 1: System.out.println( You selected 1. ”) ; break; } { case 2: , case 3 System.out.println( You selected 2 or 3. ); break; } { case 4: System.out.println( You selected 4. ); } { default: System.out.println( Select again please. ); } Q3: if (count >= 0) && (count <= 100) Q4: a) The error is not defining width or length in the pseudocode. Define variables: int width int length Display: What is the room s width
Input width Display: What is the room s length? Input length int area = width * length; // width times length Display: area b) The program will display: The value is number c) for (int count = 1, count > 10, count++); { System.out.println(count); count ++; } d) if (x == 1) y = 2; else if (x == 2) y = 3; else if (x == 3) y = 4; e) if (average == 100) System.out.println( Perfect Average! ); f) if (num2 == 0) { System.out.println("Division by zero is not possible."); System.out.println("Please run the program again ");

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture