Workshop 01
Workshop 01
Workshop 1
Part 1: Preparation
C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0\bin
Note:
You should only have one bin directory for a JDK in the path at a time. Those following the
first instance are ignored.
If you are not sure where to add the JDK path, append it.
The new path takes effect in each new command window you open after setting
the PATH variable.
1
2. Let us look at a simple code that would print the words Hello World.
publicclassMyFirstJavaProgram{
/* This is my first java program.
* This will print 'Hello World' as the output
*/
publicstaticvoid main(String[]args){
System.out.println("Hello World");// prints Hello World
}
}
Let's look at how to save the file, compile and run the program. Follow the steps given below:
Open a command prompt window and go o the directory where you saved the class. Assume
it's C:\.
Type ' javac MyFirstJavaProgram.java ' and press enter to compile your code. If there are no
errors in your code, the command prompt will take you to the next line (Assumption : The path
variable is set).
You will be able to see ' Hello World ' printed on the window.
C :>javacMyFirstJavaProgram.java
C :> java MyFirstJavaProgram
HelloWorld
1. Write a Java program to convert the starting time in hours and minutes to the equivalent total
minutes :
2
2. Write a Java program that can serve as a ending time calculator. The user enters the starting time
in hours and minutes, a duration in total minutes, and your program will calculate and display the
ending time (as hours:minutes).
For example, if an event starts at 2 30 and lasts 125 minutes, it will end at 4 35
Note: To simplify the problem, assume military time (0..23) rather than standard time, in which you
would need to worry about a.m. and p.m.