Testing First Set of Programs
Setting up Programming Environment
Although you can use an IDE, such as NetBeans, IntelliJ IDEA, and Eclipse that has already been installed by someone or use even an online IDE, such as replit and Github Codespaces, it is beneficial to understand the basic concepts of operating systems, JRE, JDK, and Editors for writing programs.
To set up a Java programming environment on a system, you don’t have to have the Administrative privilege of the system. To replicate the environment that the instructor make demos in class, follow the steps below:
- If you are using a Windows computer, download and set up Git. Go to https://git-scm.com/download/win, download the “64-bit Git for Windows Portable.” It is a “.exe” file, you can run the file (by double-clicking at it, for instance).
- Download and set up Atom Editor. Go to https://github.com/atom/atom/releases/tag/v1.60.0. Download and run the downloaded file.
- Download and set up JDK. Go to https://jdk.java.net/archive/ and download OpenJDK 17. This is a zip file. Simply unzip it.
Refer to the Programming Tools and Environments lecture slides for more details.
Writing and Testing the “Hello, World!” Program
Follow the instruction in the Introduction to Computers and Programming lecture slides.
Computing the Area of a Circle
Write a program called AreaOfCircle.java
that computes the areas of the circle
whose radius is 5.8 and print out the area on the standard output. To do this,
you need the mathematical constant \(\pi\). Java provides the constant in its Math
package called Math.PI
that you should use in your program.
Calculating GPA from Two Courses
Write a program called GPACalculator.java
that reads GPA value and credit
hours for two courses from standard input and compute GPA of the two courses,
and print the GPA on the standard output. The GPA is computed using the
following formula
For example, a user enters
4.0 3
3.0 3
The program computes the GPA, and displays the GPA as,
GPA is 3.5.
Submission
Submit your work to Lab Intro under In-Class Labs on CodeLab.