0% found this document useful (0 votes)
32 views2 pages

Program 1: and Click Save

The document provides instructions for completing hands-on activities to learn Java programming. It includes 12 steps for setting up a programming environment and compiling Java code. It then provides 5 sample Java programs - a simple "Hello World" program, programs that take user input using different methods, and a program that calculates basic math operations. The goal is for students to gain experience writing, compiling, and running simple Java programs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

Program 1: and Click Save

The document provides instructions for completing hands-on activities to learn Java programming. It includes 12 steps for setting up a programming environment and compiling Java code. It then provides 5 sample Java programs - a simple "Hello World" program, programs that take user input using different methods, and a program that calculates basic math operations. The goal is for students to gain experience writing, compiling, and running simple Java programs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

HANDS-ON ACTIVITY

Step1: On your keyboard click the window button then type cmd
Step2: Type D: for changing directory then proceed on creating your own directory.
Step3: type this: mkdir SURNAME_SECTION_SUBJECT then enter.
Step4: Type: Tree then enter
Step5: Type: start..
Step6: Go back to cmd then type: notepad
Step7: Writing codes (ctrl + s) to save
Step8: Save your file in SURNAME_SECTION_SUBJECT as Program1.java then change the file type as: All Files
and click save.
Step9: Proceed to cmd then type this: Path "C:\Program Files\Java\jdk1.8.0_151\bin" Then enter
Step10: Then type javac to check if the java compiler is ready to ready programs.
Step11: Compile your program. Type this: javac Program1.java then enter.
Step12: If no error encounter type this: java Program1 then enter.

PROGRAM 1

//My First Program


/*
Name:
Section:
Program 1
*/

public class Program1 {


public static void main(String[] args) {
System.out.println("Hello World!");
}
}

PROGRAM 2

/*
Name:
Section:
Program 2
*/

import java.io.*;
public class Program2 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String name;
System.out.print("Enter your name: ");
name = br.readLine();
System.out.println("Welcome "+ name +" To JAVA");
}
}
PROGRAM 3
/*
Name:
Section:
Program 3
*/

import java.util.Scanner;
public class Program3 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String name;
System.out.print("Enter Your Name: ");
name = s.next();
System.out.println("Welcome " + name + " to JAVA");
}
}

PROGRAM 4
/*
Name:
Section:
Program 4
*/
import java.util.Scanner;
public class Program4 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int num1, num2, sum;
System.out.print("Enter First Number: ");
num1 = s.nextInt();
System.out.print("Enter Second Number: ");
num2 = s.nextInt();
sum = num1 + num2;
System.out.print("The sum is " + sum);

}
}

PROGRAM 4A
Public class Program4A {
Expected Output:
Enter First Number: 5
Enter Second Number: 4
Sum is 9
Difference is 1
Product is 20
Quotient is 1
}

You might also like