Skip to main content

Posts

Showing posts with the label Java doc

Program to Make Canvas in Java For GUI

GRAPHICAL USER INTERFACE : CANVAS CLASS: import javax.swing.*; import java.awt.*; import java.util.List; import java.util.*; /**  * Canvas is a class to allow for simple graphical drawing on a canvas.  * This is a modification of the general purpose Canvas, specially made for  * the BlueJ "shapes" example.   *  * @author: Bruce Quig  * @author: Michael Kšlling (mik)  *  * @version 2011.07.31  */ public class Canvas {     // Note: The implementation of this class (specifically the handling of     // shape identity and colors) is slightly more complex than necessary. This     // is done on purpose to keep the interface and instance fields of the     // shape objects in this project clean and simple for educational purposes.     private static Canvas canvasSingleton;     /**      * Factory method to get t...

Java Program to make Employee Record

Employee Record  First is the Employee Class:- public class Employee {   private String firstName;   private String lastName;   private double monthlySalary;   public Employee(String f, String l, double m)  {  firstName = f;       lastName = l;       if(m < 0){  monthlySalary =0;     }       else  {  monthlySalary = m;   }  }     public String getFirstName() {      return firstName;     }     public void setFirstName(String fname) { firstName = fname;     }     public String getLastName() {    return lastName;  }  public void setLastName(String lname) {        lastName = lname;  } public double getMonthlySalary() {        return monthl...

Java Program to make a Grocery Bill

The First Class is Discount which extends the Grocery Bill Class :- public class Discount extends GroceryBill{ boolean preffered = true ; private double d=0 ; GroceryBill gb = new GroceryBill() ; public Discount(Employee e ,boolean preffered) { } // disc count amount percent ; public void DiscountCount() { int a = 0 ; for(Item i : al) { if(i.getdiscount()>0) { a++ ; } } System.out.println("------------------------------------"); System.out.println("Total Discount Items : " + a); // System.out.println("------------------------------------"); } public void DiscountAmount() { for(Item i : al) { d+=(i.getprice()*i.getdiscount()) ; } System.out.println("------------------------------------"); System.out.printf("Total Discount Amount : %.2f", d); System.out.println(""); } public void DiscountPer() { double p=0 ,...

Java Projects

How to Make Basic Java programs: Java is one of the best programming language to make GUI and many other departmental software for making computer handling software . Through java programming you can make games , calculators , ticket Machine and related software because it deals with some wide range of built in functions which every programming language do exist.. Here below is the Code through which you can easily make some basic four programs : Even or Odd : import java.util.Scanner; public class EvenorOdd { public static void main(String Args[]) { int x; System.out.println( "Enter the number" ); Scanner input = new Scanner(System.in); x=input.nextInt(); if (x % 2 ==0) System.out.println( "The number is even" ); else System.out.println( "The number is odd" ); } } Radius :