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.
top of page
bottom of page
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); } }
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);
}
}
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);
}
}
}
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); } }
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);
}
}