Sign in. Page. 1. /. 69. Loading⦠Page 1 of 69. CPS109. with Prof. Kosta Derpanis. COMPUTER SCIENCE 1. Part 2. Strings
CPS109
COMPUTER SCIENCE 1 with Prof. Kosta Derpanis
Strings Part 2
Why
CS?
software engineering application of a systematic, disciplined, quantifiable approach to the development, operation and maintenance of software
6 1 0 2 E S U R / m o c . tinyurl
3 8 2 G N E e c i f f O S C n i Ma
CPS109
COMPUTER SCIENCE 1 with Prof. Kosta Derpanis
Strings Part 2
Administration
responsible for following any directives so sent. As course topics typically develop based on material from previous lectures, students are strongly urged to attend ALL classes. If you miss any material due to illness or other unavoidable circumstance be sure to catch up before the next class. Grades on assignments, tests and labs will be available on the Blackboard/RAMSS system or other means specified by your professor. As per Ryerson regulation, final exam marks and grades d r 3 r e b o t c O f o k e e W will be disclosed only by the registrar's office. 1 # z i u Q b La
SLG
Supported Learning Groups Student Learning Centre (SLC) 453 Mondays 2pm - 3pm Tuesdays 12pm - 1pm Wednesdays 12pm - 1pm
Jordan Kilfoy group lead
Google @ Ryerson G-103 October 4th @ 6PM, EN
ring process, culture, hi ’s le og Go t ou ab e or Learn m nities, and more! job/internship opportu me! development is welco e ar ftw so in st re te in Anyone with an /5b0Mwu Sign up at http://goo.gl omen in CS Event W n so er Ry @ le og Go October 4th process, culture, g rin hi , rts fo ef ity rs ve le’s di Learn more about Goog nities, and more! job/internship opportu 6br2l1 /forms/DDFlXRZMNxW gl o. go // s: tp ht at up Sign l Career Workshop
chnica Google @ Ryerson - Te October 4th
get ogle and tips on how to Go at s es oc pr g rin hi ws. Learn more about the ul in technical intervie sf es cc su be d an n io through the applicat s/MfHYqiDv7Y4jb93F2 m or /f gl o. go // s: tp ht Sign up at
Google @ Ryerson - Oc google.com/students
tober 4th
s t c e j b O e t a L : a v a J g i B , n n a m t s r o H
LECTURE TOPICS
LECTURE TOPICS String input
LECTURE TOPICS String input Formatted output
Hello, World!
import javax.swing.*;
Dialog public class GUI_Example Boxes { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter a string"); JOptionPane.showMessageDialog(null, input); } }
import javax.swing.*; public class GUI_Example { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter a string"); JOptionPane.showMessageDialog(null, input); } }
import javax.swing.*; public class GUI_Example { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter a string"); JOptionPane.showMessageDialog(null, input); } }
import javax.swing.*; public class GUI_Example { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter a string"); JOptionPane.showMessageDialog(null, input); } }
import javax.swing.*; public class GUI_Example { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter a string"); JOptionPane.showMessageDialog(null, input); } }
Hello, World!
import javax.swing.*; public class GUI_Example { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter a string"); JOptionPane.showMessageDialog(null, input); } }
import javax.swing.*; public class GUI_Example { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter a string"); JOptionPane.showMessageDialog(null, input); } }
import javax.swing.*; public class GUI_Example { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter a string"); JOptionPane.showMessageDialog(null, input); } }
d e t t a Form Output
System.out.println
System.out.print
System.out.printf
Formatte d Output
int number = 15; System.out.printf("Number is %d.", number);
Console
Formatte d Output
int number = 15; System.out.printf("Number is %d.", number);
Console
Formatte d Output
format specifier
int number = 15; System.out.printf("Number is %d.", number);
Console
Formatte d Output
int number = 15; System.out.printf("Number is %d.", number);
e u l a v t u p t u o Console
Formatte d Output
int number = 15; System.out.printf("Number is %d.", number);
Console Number is 15.
Format Specifiers "%d"
Examples
Format Specifiers "%d" "%5d" "%f" "%.2f" "%7.2f" "%s" "%d %.2f"
Examples
int num = 9; System.out.printf("%5d", num);
Console
int num = 9; System.out.printf("%5d", num);
) d e i f i t s u j t h g i r ( s e c a l p n s e v r e s re
Console
int num = 9; System.out.printf("%5d", num);
Console _ _ _ _ 9
int num = 9; System.out.printf("%5d", num);
Console _ _ _ _ 9
spaces
int num = -38; System.out.printf("%6d", num);
Console
int num = -38; System.out.printf("%6d", num);
? t u p t u o e h t What is Console
int num = -38; System.out.printf("%6d", num);
Console _ _ _ -38
int num = -38; System.out.printf("%6d", num);
negative sign takes up Console _ _ _ -38
a position
int num = 567; System.out.printf("1234%2d8910", num);
Console
int num = 567; System.out.printf("1234%2d8910", num);
Console
int num = 567; System.out.printf("1234%2d8910", num);
? t u p t u o e What is th Console
int num = 567; System.out.printf("1234%2d8910", num);
Console 12345678910
System.out.printf("Number is %-8d.\n", 1234);
Console
System.out.printf("Number is %-8d.\n", 1234);
) d e i f i t s u j t f e l ( s reserves n place
Console
System.out.printf("Number is %-8d.\n", 1234);
) d e i f i t s u j t f e l ( s reserves n place
Console Number is 1234 _ _ _ _ .
double num = 1.21997; System.out.printf("%f", num);
Console
double num = 1.21997; System.out.printf("%f", num);
Console 1.21997
double num = 1.21997; System.out.printf("%.2f", num);
Console
double num = 1.21997; System.out.printf("%.2f", num);
Console
double num = 1.21997; System.out.printf("%.2f", num);
r e t a e r g s i n o i s i c e r p f i l a m i c e d s d roun
Console
double num = 1.21997; System.out.printf("%.2f", num);
Console 1.22
double num = 3.14159265359; System.out.printf("%10.2f", num);
Console
double num = 3.14159265359; System.out.printf("%10.2f", num);
Console _ _ _ _ _ _ 3.14
double num = 3.14159265359; System.out.printf("%10.2f", num);
decimal point takes up Console _ _ _ _ _ _ 3.14
a position
String greeting = "Hello"; System.out.printf("%s, World!", greeting);
Console
String greeting = "Hello"; System.out.printf("%s, World!", greeting);
Console Hello, World!
String coursePrefix = "CPS"; int courseNum = 109; double avg = 80.235; System.out.printf("Average mark in %s%d: %6.2f\n", coursePrefix, courseNum, avg);
Console
String coursePrefix = "CPS"; int courseNum = 109; double avg = 80.235; System.out.printf("Average mark in %s%d: %6.2f\n", coursePrefix, courseNum, avg);
? t u p t u o e What is th Console
String coursePrefix = "CPS"; int courseNum = 109; double avg = 80.235; System.out.printf("Average mark in %s%d: %6.2f\n", coursePrefix, courseNum, avg);
Console Average mark in CPS109: _ _ 80.24