Can you pinpoint what is wrong with this code?please explain thank you. import j
ID: 3780789 • Letter: C
Question
Can you pinpoint what is wrong with this code?please explain thank you.
import java.util.Scanner;
public class InputOutput
public static void main(String[]args){
System.out.println("Print first ");
System.out.println("Print second ");
System.out.println("Print third");
System.out.println("Print fourth");
System.out.println("Print fifth");
Scanner input = new Scanner(System.in);
System.out.println("What is your favorite color? ");
String color = input.nextLine();
System.out.println("You wrote: " + “color”);
System.out.println("How many apples do you have? ");
numApples = scnr.nextInt();
System.out.println("You wrote: " + numApples);
return;
}
}
Explanation / Answer
public class RangeFilter { public static void main(String[] args) { // read in two command-line arguments int lo = Integer.parseInt(args[0]); int hi = Integer.parseInt(args[1]); // repeat as long as there's more input to read in while (!StdIn.isEmpty()) { // read in the next integer int t = StdIn.readInt(); // print out the given integer if it's between lo and hi if (t >= lo && tRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.