Hard work beats talent when talent doesn’t work hard.
--Your friends at LectureNotes

Lab Manuals for Java Programming - JAVA By MOSHECK MENTA

  • Java Programming - JAVA
  • Practical
  • Computer Science Engineering
  • 3 Offline Downloads
  • Uploaded
Mosheck Menta
Mosheck Menta
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

WEEK-1 1. Use Eclipse or Netbean platform and acquaint with the various menus.Create a test project,add a test class and run it.See how you can use auto suggestions,auto fill.Try code formatter and code refactoring like renaming variables,methods and classes.Try debug step by step with a small program of about 10 to 15 lines which contains at least one if else condition and a for loop. Program:import java.util.*; public class Testp { public static void main(String[] args) { System.out.println("Welcome to Kshatriya Engineering College"); System.out.println("--------Prime Number--------"); Scanner sc = new Scanner(System.in); System.out.println("Enter valid Number"); int n = sc.nextInt(); int c = 0; for (int i = 1; i <= n; i++) { if (n % i == 0) { c++; } } if (c == 2) { System.out.println(n + "is Prime Number"); } else { System.out.println(n + "is not Prime Number"); } } } Page 1

Text from page-2

OUTPUT: Page 2

Text from page-3

Page 3

Text from page-4

WEEK-2 2. Write a Java program that works as a simple calculator. Use a grid layout to arrange buttons for the digits and for the +,-,*, % operations. Add a text field to display the result. Program://<applet code="Calculator.class" height="150" width="700"></applet> import java.applet.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Calculator extends Applet implements ActionListener { JTextField t1,t2,t3; JLabel l1,l2,l3; JButton b1,b2,b3,b4; JPanel p1,p2; public void init() { p1=new JPanel(); p2=new JPanel(); p1.setBackground(Color.gray); p2.setBackground(Color.gray); setBackground(Color.lightGray); l1=new JLabel("Enter the First number:"); p1.add(l1); t1=new JTextField(10); p1.add(t1); l2=new JLabel("Enter the second number:"); p1.add(l2); t2=new JTextField(10); p1.add(t2); l3=new JLabel("Result"); p1.add(l3); t3=new JTextField(10); p1.add(t3); b1=new JButton("ADD"); p2.add(b1); b1.addActionListener(this); Page 4

Lecture Notes