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, https://replit.com/, it is benefical to understand the basic concepts of operating systems, JRE, JDK, and Editors for Programmers.
To set up a Java programming environment on a system, you don’t have to have the Administrative privilege of system.
- 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://atom.io/. 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. Simple unzip it.
Refer to Programming Tools and Environments for details.
Writing and Testing the “Hello, World!” Program
Following the instruction in the Overview 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 a 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
GPA = ((GPA Value 1)(Credits 1)+(GPA Value 2)(Credits 2) ) /((Credits 1)+(Creits 2))
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.