Download presentation
Presentation is loading. Please wait.
Published byArchibald Spencer Modified over 8 years ago
1
CPSC 233 Tutorial January 21 st /22 nd, 2015
2
Linux Commands
3
Primitive Types byte short int long float double boolean char
4
Variable Assignment int num = 5; char c = ‘a’; boolean bool = true; long longNum = 100l; float floatNum = 1.5f;
5
String A String represents a sequence of characters. String text = “Hello World”; String character = “a”; “a” vs. ‘a’ == vs..equals()
6
Printing to Console System.out.println(“Hello); String word = “Hello”; System.out.println(word); int num = 5; System.out.print(num); print vs. println
7
If Statements Used for Control flow. Execute a piece of code only if some condition is true
8
If Statements If ( ){ }
9
If Statements If ( ){ } else ( ){ }
10
If Statements If ( ){ } else if ( ){ } else if ( ){ }
11
If Statements If ( ){ } else if ( ){ } else if ( ){ } else { }
12
Scanners A Java class that allows the program to read input. Read from console Read from file
13
Scanner
14
Exercise Write a Java program that prompts the user for the course program (“CPSC”) and the course number (233) and checks if it matches this course. i.e. “CPSC” and 233. Print a message that states if the input matches or not. Compile: javac InputMatch.java Run: java InputMatch
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.