logotransparent.png

Legion of Learners

www.lol-101.com

  • Home

  • Classrooms

  • Courses

  • About Us

    • Executive Team
    • Board Members
  • Resources

  • More

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    kevinzhao183
    Jul 12, 2020

    Intro to Java 7/11 Homework

    in Java Question Bank

    Please complete number one on this page: https://www.lol-101.com/classrooms/introduction-to-java/4-3-how-to-run-part-of-code-under-certain-conditions. Feel free to modify the existing code to reach your answer or write your own program(for more practice), and then comment your solution here. If modifying the given program, replace the "..." in the if statement with the appropriate boolean expression to complete the program. Don't worry about the grey text that is either enclosed in /* and */ or started off with //, those are comments and do not affect the code.

    5 comments
    0
    isaac.k.hsu
    Jul 12, 2020  ·  Edited: Jul 12, 2020

    import java.util.Scanner;

    public class Elevator {

    public static void main(String[] args) {

    Scanner in = new Scanner(System.in);

    System.out.print("Floor: ");

    int floor = in.nextInt();

    int actualFloor;

    if (floor >= 13) {

    actualFloor = floor - 1;

    } else {

    actualFloor = floor;

    }

    System.out.println("The elevator will travel to the actual floor " + actualFloor);

    }

    }

    0
    andymei2007
    Jul 15, 2020

    import java.util.Scanner; /** This program simulates an elevator panel that skips the 13th floor. */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Floor: "); int floor = in.nextInt(); // Adjust floor if necessary int actualFloor; if (floor >= 13) // What's missing here? { actualFloor = floor - 1; } else { actualFloor = floor; } System.out.println("The elevator will travel to the actual floor " + actualFloor); } }

    0
    leosong23
    Jul 15, 2020

    import java.util.Scanner;

    public class Hw_7_11Class {

    public Hw_7_11Class() {

    // TODO Auto-generated constructor stub

    }

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    Scanner in = new Scanner(System.in);

    System.out.print("Floor number: ");

    int floor = Integer.parseInt(in.next());

    in.close();

    int actual_floor;

    if (floor >= 14)

    {

    actual_floor = floor - 1;

    System.out.println("Actual floor number: " + actual_floor);

    }

    else

    {

    actual_floor = floor;

    System.out.println("Actual floor number: " + actual_floor);

    }

    }

    }


    0
    ivanyu521
    Jul 15, 2020

    import java.util.Scanner;

    /** This program simulates an elevator panel that skips the 13th floor. */

    public class Elevator {

    public static void main(String[] args) {

    Scanner in = new Scanner(System.in);

    System.out.print("Floor: ");

    int floor = in.nextInt();

    // Adjust floor if necessary

    int actualFloor;

    if (floor >= 13) {

    actualFloor = floor - 1;

    } else {

    actualFloor = floor;

    }

    System.out.println("The elevator will travel to the actual floor " + actualFloor);

    }

    }

    0
    nathanshimizu2016
    Jul 16, 2020

    import java.util.Scanner; /** This program simulates an elevator panel that skips the 13th floor. */ class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Floor: "); int floor = in.nextInt(); // Adjust floor if necessary int actualFloor; if (floor>=13) // What's missing here? { actualFloor = floor - 1; } else { actualFloor = floor; } System.out.println("The elevator will travel to the actual floor " + actualFloor); } }

    0
    5 comments

    Questions? Email us at legionoflearners@gmail.com or join our WeChat group!

    • lol-101dotcom

    ©2020 Legion of Learners