CSC 111 Lecture Notes - Lecture 5: Carriage Return, Concatenation

35 views3 pages

Document Summary

Input-output: scanner class, used for keyboard and file input, at beginning of file you need to import the utility. Import java. util. scanner: declare keyboard object which is of type scanner, scanner kbd = new scanner(system. in) Integer/double input: system. in is what accepts data in from keyboard, read next integer, kbd. nextint( ), read next double, kbd. nextdouble( ), horizontal: 7. 2: read next int up until a space, vertically: I(cid:373)plies (cid:455)ou"d ha(cid:448)e (cid:1007) of these as three separate thi(cid:374)gs i(cid:374) order: more done with interactive response, string input, read next string token, token an item of a piece of data. Reads until space: e(cid:454): (cid:862) ja(cid:448)a is fu(cid:374)(cid:863) If i is less tha(cid:374) the le(cid:374)gth of the li(cid:374)e the(cid:374) pri(cid:374)t out the (cid:272)hara(cid:272)ter at i"s position: reading an int, applies more to files than keyboard. Int n1 = 20: double n2 = 12. 47283, (cid:455)ste(cid:373). out. pri(cid:374)tf(cid:894) (cid:862) % 5d , % 7. (cid:1006)f (cid:863), (cid:374)(cid:1005), (cid:374)(cid:1006)(cid:895), output will look like this:

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

Related Questions