Anda di halaman 1dari 9

DOROIN

I. TITLE: Program 3

II. OBJECTIVES

2.1. To know how to make a simple java program.

2.2. To make a program that will run through CMD.

III. MATERIALS

3.1. One PC with with Java and Java Development Kit (JDK) installed.

IV. THEORY

Java is widely used programming language that is used to make an applets or

background apps (mini apps). It is the most used programming language used in

android smartphones and is among the most favored for edge device and internet of

things development.

Command prompt or widely known as CMD is a command line interpreter

application that are available in all windows OS. This built in app is used to execute

different commands in order for the other apps to work or sometimes used in

troubleshooting and perform advanced administrative functions.

V. PROCEDURES

5.1. Program 3A

5.1.1. Install the Java Development Kit (JDK). The Java program is already

included in that kit.

5.1.2. Make a program that will add, subtract, multiply and divide two

numbers inputted by the user.

5.1.3. In this case, the basic Java program (Hello world type) will not work.

In order for the program to work, you have to introduce “scanner”

“import java.util.Scanner;

public class MiguelKarlousDoroin6{

public static void main (String[]args){“

In the start of the program, we need to introduce the scanner by

using the line “import.java.util.Scanner;” and then the class file and

the string.

Page 1 of 9
DOROIN
5.1.4. After setting the data values, we have to type the codes below:

Scanner in=new Scanner (System.in);

System.out.println ("Enter value a");

a = in.nextFloat();

System.out.println ("Enter value b");

b = in.nextFloat();

Through this codes, we can input different digits in our program in

CMD later.

Figure 5.1.4 Making a program that will let you use the basic arithmetic operation

5.1.5. Save it as a java file with a file name same with the class name made

in the program. In my case, I will name it

“MiguelKarlousDoroin6.java”. For easier access, you may save it in

the desktop.

5.1.6. After saving it, you may now use the Command Prompt (CMD) in

order for you to be able to run the program.

Page 2 of 9
DOROIN

Figure 5.1.6 Command Prompt

5.1.7. Look for the path of the bin that can be found in the drive C > Program

Files or Program Files (x86) for other PC.

Figure 5.1.7 Path of the bin of Java

5.1.8. After finding the bin, you can copy the path and paste it to CMD with

a command “path C:\Program Files\Java\jdk1.8.0_144\bin”

5.1.9. Specify the location of your Java file that you made a while ago. Since

it is located in the desktop, type “cd desktop”.

5.1.10. In order for you to run the java file and convert it to class file, type

“javac (filename).java”.

Page 3 of 9
DOROIN
5.1.11. When there is no error in your program, Type “java (filename) in

order for your file to pop up in the CMD. It should be shown just like

the figure below.

Figure 5.1.11 The Final output in the CMD

5.2. Program 3B

5.2.1. If there is no Java Development Kit (JDK) installed in your PC,

download it and install.

5.2.2. Make a program that allows user to input grade for prelims, midterm,

finals of a particular subject then display the final grade.

5.2.3. In this case, the basic Java program (Hello world type) will not work.

In order for the program to work, you have to introduce “scanner”

“import java.util.Scanner;

public class MiguelKarlousDoroin6{

public static void main (String[]args){“

In the start of the program, we need to introduce the scanner by

using the line “import.java.util.Scanner;” and then the class file and

the string.

5.2.4. After setting the data values, we have to type the codes below:

float a = 0;

Page 4 of 9
DOROIN
float b = 0;

float c = 0;

float d = 0;

float e = 0;

float f = 0;

Scanner in=new Scanner (System.in);

System.out.println("Summary of Grades - Statics and Dynamics of

Rigid Body");

System.out.println (" ");

System.out.println ("Quiz # 1 - Prelim");

a = in.nextFloat();

System.out.println ("Quiz # 2 - Prelim");

b = in.nextFloat();

Float g = (a+b)/2;

System.out.println (" ");

System.out.println ("Prelim Grade is: "+g+"!");

System.out.println (" ");

System.out.println ("Quiz # 1 - Midterm");

c = in.nextFloat();

System.out.println ("Quiz # 2 - Midterm");

d = in.nextFloat();

Float h = (c+d)/2;

System.out.println (" ");

System.out.println ("Midterm Grade is: "+h+"!");

System.out.println (" ");

System.out.println ("Quiz # 1 - Finals");

e = in.nextFloat ();

System.out.println ("Quiz # 2 - Finals");

f = in.nextFloat ();

Page 5 of 9
DOROIN
Float i = (e+f)/2;

System.out.println (" ");

System.out.println ("Finals Grade is: "+i+"!");

System.out.println (" ");

Float j = (g+h+i)/3;

System.out.println ("Your Final Grade is "+j+"!");

Through this codes, we can input different digits in our program in

CMD later.

Figure 5.2.4 Making a program that will let you compute the grades per term and the final grade

5.2.5. Save it as a java file with a file name same with the class name made

in the program. In my case, I will name it

“MiguelKarlousDoroin7.java”. For easier access, you may save it in

the desktop

5.2.6. After saving it, you may now use the Command Prompt (CMD) in

order for you to be able to run the program.

Page 6 of 9
DOROIN

Figure 5.2.6 Command Prompt

5.2.7. Look for the path of the bin that can be found in the drive C > Program

Files or Program Files (x86) for other PC.

Figure 5.2.7 Path of the bin of Java

5.2.8. After finding the bin, you can copy the path and paste it to CMD with

a command “path C:\Program Files\Java\jdk1.8.0_144\bin”

5.2.9. Specify the location of your Java file that you made a while ago. Since

it is located in the desktop, type “cd desktop”.

5.2.10. In order for you to run the java file and convert it to class file, type

“javac (filename).java”.

Page 7 of 9
DOROIN
5.2.11. When there is no error in your program, Type “java (filename) in

order for your file to pop up in the CMD. It should be shown just like

the figure below.

Figure 5.2.11 Final output in CMD

IV. OBSERVATION/ DISCUSSION

Basic Java programming is simple as long as we know the basic commands that

will be used. I observed that almost everything is possible in this programming

application but there is limitation in some ways. I found it interesting because I can

make a simple programming that can be run through CMD. We can also make a

program that can assign different formulas and let the user input the values using the

scanner. It will be useful in some ways. But today, knowing that we are already

technologically advanced, we may not use this type of programming as we already

have different advanced programming technique.

V. CONCLUSION

Therefore, I conclude that this Java programming may be used by beginners in

programming world. Java will introduce us to the wider and broader world of

programming. For now, it is very useful because it is widely used in Android

smartphone programming and it is really important for us to know the basics.

VI. REFERENCE

Page 8 of 9
DOROIN
6.1. Internet Sites

 Fisher, T. (n.d.). What Is The Command Prompt in Windows, and How Do

I Open It? Retrieved October 02, 2017, from

https://www.lifewire.com/command-prompt-2625840

 WhatIs.com. (n.d.). Retrieved October 02, 2017, from

http://www.theserverside.com/definition/Java

Page 9 of 9

Anda mungkin juga menyukai