Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lab 2a: Calculating the Area of a Circle in Java - CSCI 161, Lab Reports of Computer Science

Instructions for lab 2a of the introduction to programming i course (csci 161) at the university level. Students are required to create a java project named 'lab2area' and write a program to calculate the area of a circle using the given radius and the constant value of pi. The document also suggests using comments and static methods to eliminate redundancy. No input is required, and the output will display the calculated area of the circle.

Typology: Lab Reports

Pre 2010

Uploaded on 08/16/2009

koofers-user-a7k
koofers-user-a7k 🇺🇸

10 documents

1 / 1

Toggle sidebar

Related documents


Partial preview of the text

Download Lab 2a: Calculating the Area of a Circle in Java - CSCI 161 and more Lab Reports Computer Science in PDF only on Docsity! CSCI 161: Introduction to Programming I Lab 2a: Area Due 9/16/08 by 11:59 PM Goals - to use the basic concepts of variables and primitive data we have learnt so far Overview 1. Start a new project in Java – call it “Lab2Area” (one word) 2. Start a new class within the new project, call it “Area” 3. Using comments to write your name and information about this class. 4. Notice that Eclipse will create the class called “Area” and method called “main” for you. Also notice the indentations that occur after each curly bracket. 5. Write a complete program to calculate the area of a circle Output Specification Output the initial area of a circle; define the variable named “pi” and the variable named “radius” Give the variable radius an initial value of 5 Sample Output: The area for this circle is: 75.0 6. Run the program, and then submit your work to Hardy161 Lab2Area. The file being submitted should be Area.java Input Specification No input is required. Required Methods Use several static methods to eliminate redundancy. Hints Create a new project for this lab. The basic steps are the same as in the first lab. In Eclipse, go to File-> New -> Project and create a Java Project. Under "Project layout", be sure to select "Use project folder as root for sources and class files". Name your project (e.g."Lab2Area"). Next create a new Java class file by clicking on the "New Java Class" button. Name the class (e.g., "Area"). Under "Which method stubs would you like to create?", be sure to click on the box to create "main".