CSC 120 Lecture Notes - Lecture 10: Newline

73 views4 pages
Verified Note

Document Summary

System. out. printf((cid:1688)(cid:1689)) prints objects, but one can freely format their text using printf. Just like system. out. print and system. out. println, this printf prints onto the console. I will show every example on the code: public class hw2 public static void main( string[] args ) String name; name = tem; int num; num=6969; double number; number = 77. 88. How to use system. out. printf((cid:1688)string(cid:1689) , argument): format specifier: %c: character (capital c will uppercase the letter) %s: string (capital s will uppercase all the letters in the string) Hello tem: if . n is before the specifier, then first n letter/ number will be shown ex: Number 6,696: examples of decimal from slide(slide 10), examples of float from slide(slide13, 16), examples of string(silde 19) To print % in printf you need %%(2) Your name is tem your favorite number is 6969: you can combine all these ex: System. out. printf((cid:1688)hi %s, your favorite number is %d(cid:1689), name, num);

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents