0
what is the meaning of this code line: System.out.println("Special Customer <Yy/Nn>:?");
Its a code line from one of my textbook program. I don't know what does it mean.
7 Réponses
+ 3
this statement ask the user if he is special customer enter Y or y .and if he is not to enter N or n ...easy..
+ 1
System.out.print (); is a statement the prints output.
inside the () you pass the arguments you want to be output ed to a screen. you had the string literal "Special Customer <Yy/Nn>:?" passed into the argument.
there for output to screen is:
Special Customer <Yy/Nn>:?
+ 1
its just a way to explain to the user what answer is expected.. With --- System.out.println() --- you show a message and the idea is that the user write -- y or Y -- if is talking about a special customer on -- n or N -- in other case... for example in a supermarket or some place like that... sorry for the english, gretings from Argentine
0
The term in your text book
System.out.println("Special Customer <Yy/Nn>:?");
Actually means that the user has to input either a Capital letter or a Small letter of Y or N.
Any of the input runs through a switch or if/else statement to determine the actual context or reply it is going to display next.
if non of d required character "char type" is keyed into d program, it prints a default statement or else statment.
- 1
System is a class and println is a method of another class named input stream, and .out is an instance of class input stream stored as a data member of class System.
- 2
It prints out: Special Customer <Yy/Nn>:?
Anything within the double quotes will be printed to the console.
System.out.println("Hello"); //This will print 'Hello' to the console.
Go to an IDE and test it out for yourself.
- 2
^^ System.out.println(""); is a method created in Java that prints whatever is in the quotes, if you want to print a value thats stored in a variable:
int x = 15;
System.out.println("X is: " + x);