CSE 142 Lecture 2: 2 Introduction to CSE 142

42 views2 pages
Verified Note
28 Sep 2018
School
Course

Document Summary

Week 1 class 2 (cid:1006) introduction to cse (cid:1005)4(cid:1006) I(cid:374) refere(cid:374)(cid:272)e to the (cid:862)helloworld(cid:863) program, public class helloworld{ public static void main(string[] args) { Statements are (cid:862)(cid:272)ode that does so(cid:373)ethi(cid:374)g(cid:863) - system. out. println() Strings are (cid:862)text that is goi(cid:374)g to (cid:271)e pri(cid:374)ted out(cid:863), a(cid:374) i(cid:374)put to the state(cid:373)e(cid:374)t (cid:862)hello, world! (cid:863) Inefficient code (will only score about 11 or 12 out of 20): public class diamondcross_1 { public static void main(string[] args) { We can make the code more efficient by assigning methods. A method is (cid:862)a chunk of code that i can give names to. (cid:863) This method has assigned the statement figure1 to print out: Afterwards, we can call out from figure1 by writing down figure1(); Thus, methods allow us to improve the efficiency of our code by removing redundancy. Efficient code (will score about 15 to 16 out of 20): public class diamondcross_2 { public static void main(string[] args) { diamond(); space(); diamond (); space();

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 Questions