#Need Help!

24 messages · Page 1 of 1 (latest)

paper orbit
#

The question is in one of the screenshot.


public class LabProgram {
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in); 
      int baseChar; 
      int headChar; 
      
      /* Type your code here. */
      int baseChar = 0;
      int headChar = 1;
      System.out.print("  " + baseChar);
      System.out.print("  " + baseChar + baseChar);
      System.out.print("" + headChar + headChar + headChar + headChar + headChar + baseChar + baseChar + baseChar);
      System.out.print("" + headChar + headChar + headChar + headChar + headChar + baseChar + baseChar + baseChar + baseChar);
      System.out.print("" + headChar + headChar + headChar + headChar + headChar + baseChar + baseChar + baseChar);
      System.out.print("  " + baseChar + baseChar);
      System.out.print("  " + baseChar);

}
}

This is my program, however keeps running into errors. How can I fix it?

hollow troutBOT
#

This post has been reserved for your question.

Hey @paper orbit! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

simple umbra
#

you cant declare it twice , but you can set what they equal to.
also, i believe you need to use that scanner class to get input and not hardcode 0 and 1

#

baseChar =
instead of int baseChar =

#

also, look at the example print, count the blank spaces, it looks like 5 from where im sitting before the arrow head starts

#

@paper orbit

#

one more thing....im pretty sure baseChar would be used for the zeros in the example
and headChar is being used for the one's

paper orbit
simple umbra
#

have you ever used this
Scanner scnr = new Scanner(System.in); ?

simple umbra
#

you can google the common methods for it, but in your case you want the one to get an integer

#

once you get this step figured out, the next step is to get your print statements correct.
they were close, but missing some spacing and the variables were backwards

paper orbit
#
      int headChar = scnr.nextInt();
simple umbra
#

yeah but since they already declared those variables for you ...
you need to remove the int

#
     baseChar = scnr.nextInt();
     headChar = scnr.nextInt();
#

oh 1 more thing i just noticed ..your print statements should probably be using the .println instead of just .print

paper orbit
hollow troutBOT
simple umbra
#

nice