Program 1: and Click Save
Program 1: and Click Save
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
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
}