Presentation is loading. Please wait.

Presentation is loading. Please wait.

Output THE BASICS. What is Output? Output is the information that comes FROM a computer OUT to a user Sometimes this information is feedback to an action.

Similar presentations


Presentation on theme: "Output THE BASICS. What is Output? Output is the information that comes FROM a computer OUT to a user Sometimes this information is feedback to an action."— Presentation transcript:

1 Output THE BASICS

2 What is Output? Output is the information that comes FROM a computer OUT to a user Sometimes this information is feedback to an action we perform, like typing or it is simply automated like a screensaver or the next song in your playlist playing. This information can come in a variety of forms from a variety of sources. The next few slides will discuss these mediums and sources

3 Output Examples Images ◦Images come to us typically from a screen, but depending on the device they may come in other ways. ◦Virtual Reality devices use overlapping dual screens to achieve the 3D effect ◦Holograms typically reflect the image off a volumetric substance like fog or mist Sound ◦Sound come to us from either speakers or headphones. One is a personal experience whereas the other is a community experience meant for everyone Hardcopy Print ◦Printouts are similar to images except they come to us through a machine so we can have a real world representation of the image. However, with new advances in technology we can also print 3D objects

4 Output Examples Haptic Feedback ◦This is a sense of touch for the purpose of immersing us in an experience ◦We have seen this commonly in gaming controllers, the vibration effect while shooting a gun ◦We also see it in phones while you type to give you the sense that you have typed a letter ◦There is heavy research in this field to further immerse us in the world of virtual reality Text Output ◦This is by far the most common form of output since computers entered our homes a few decades ago. ◦We see this text output in emails, webpages, video games and many other places. ◦Browsing the internet only 20 years go was a primarily text based experience for the simple fact that download speeds were not fast enough for images, sound and video at the time. Today we will focus on the most basic form of output, Text.

5 Notes While programming, when we want to tell the compiler to treat something as text we simply wrap our information in quotes, e.g. “hi” ◦This is similar to quoting someone in a report or an essay ◦Note that if you wrap numbers in quotes, e.g. “55”, it is not treated as a number but rather as text, it no longer has a numeric value In Java, text output is displayed in the Console tab at the bottom of the Eclipse editor when we run our programs ◦If this tab is not visible, click Window  Show View  Console

6 Java Text Output: Option 1 Option 1: System.out.println(“Your text here!”); System is a keyword that implies the foundation of most Java commands The dots in between each keyword represent ownership, e.g. out is a command owned by the System code foundation mentioned above out is the command to be executed from System, basically it means output to the screen println is the command owned by the out code set, that is to say println is only one of the multiple types of screen output possible The round brackets are where we put our information needed by the println command for it to do its job. Sometimes commands require one piece of information, as shown here, sometimes many or none. Another term for one of these needed pieces of information is a parameter Finally, we end all commands in Java with a semi-colon. Think of it like a period at the end of a sentence.

7 System.out.println(“text”); In the Console tab there is an invisible cursor (that blinking line you see in Word that tells you where you are about to type) ◦This cursor starts at the left of the window What does System.out.println(“text”); do? ◦println is short for print line ◦Whenever we call the println command, Java will print your text on the screen and move the cursor down to the left side of the next line below for the next output command

8 Java Text Output: Option 2 Option 2: System.out.print(“Your text here!”); We see here that the only difference is that instead of println, we simply have print What does System.out.print(“text”); do? ◦Whenever we call the print command, Java will print your text on the screen but this time the cursor will stay on the same line and be directly after your last character of output ◦This means that if you did another print command, it would appear in the Console directly after your first output and on the same line

9 Notes Remember that syntax is the grammar of the language, a set of rules that MUST be followed. If we fail to follow the rules, the program will fail and not execute. ◦E.g. What if we forget the quotes, or even one quote? ◦No quotes: System.out.println(Hi); ◦The program will fail, not run at all. If we mouse over the little red and white x to the left of the code we wrote it will say: “Hi cannot be resolved to a variable” ◦Basically this means it doesn’t know we wanted text because it cannot find the quotes ◦Missing one quote: Sytem.out.println(“Hi); ◦The program will fail, not run at all. If we mouse over the little red and white x to the left of the code we wrote it will say: “String literal is not properly closed by a double-quote” ◦Basically it tells us we are missing one of our quotes NOTE: ◦Whenever our program fails to run, we get an error window telling us there was a problem and asks us if we want to “Proceed” anyway. You answer is ALWAYS “Cancel”. Otherwise it will run that last working set of code, this is not useful at all.


Download ppt "Output THE BASICS. What is Output? Output is the information that comes FROM a computer OUT to a user Sometimes this information is feedback to an action."

Similar presentations


Ads by Google