1 / 6

CS 240 – Computer Programming I Lab

This lab session covers fundamental programming concepts including method definitions and usage in Java. You will learn how to declare methods with different return types, such as `int` and `void`, and how to utilize access modifiers. We will provide examples illustrating the return of values and calling static methods. In the lab, you will implement a method to gather user input for shapes and follow the grading criteria for post-labs and projects. Make sure to attend office hours for any queries.

enoch
Download Presentation

CS 240 – Computer Programming I Lab

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 240 – Computer Programming ILab KalpaGunaratna – kalpa@knoesis.org http://knoesis.wright.edu/researchers/kalpa/

  2. Contact • Contact by e-mail • kalpa@knoesis.org • Office hours • 376 Joshi • Mondays & Wednesday 3:00 pm – 4:00 pm

  3. Methods • <access modifier> <return type> <method name>(<parameters>){ } • Example: • private intgetAge() { return <something of int type>; } The above method returns an int value and some int value should be returned.

  4. Example : public static void doCalc() { body } Since above method is of type “void” it does not return anything. Because it is “static” you can directly call it from anywhere using the class name it belongs to. If the class it belongs to is Calculations, it can be called by Calculations.doCalc(); .

  5. In Lab • Do the lab having one method to get user input for the size of the shae.

  6. Post Lab • Use methods to get user input for the character to print the shapes. • Please follow the grading scheme when you do post labs and projects.

More Related