0% found this document useful (0 votes)
82 views14 pages

BlueJ Program Examples for Beginners

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views14 pages

BlueJ Program Examples for Beginners

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

*;

public class product

public static void main()

Scanner cs=new Scanner([Link]);

int n1, n2, pro=0;

[Link]("Enter first no. ");

n1=[Link]();

[Link]("Enter second no. ");

n2=[Link]();

pro=n1*n2;

[Link]("product of these two nos. is "+pro);

import [Link].*;//step 1

public class average

public static void main() throws IOException

[Link]("\u000c");

BufferedReader br=new BufferedReader(new InputStreamReader([Link]));//step2


[Link]("Enter First No.: ");

int num=[Link]([Link]());//step3

[Link]("Enter Second No.: ");

int num1=[Link]([Link]());

[Link]("Enter Third No.: ");

int num2=[Link]([Link]());

double avg=(num+num1+num2)/3;

[Link]("Average of three numbers is: "+avg);

import [Link].*;//step 1

public class average_sc

public static void main()

[Link]("\u000c");

Scanner sca=new Scanner([Link]);//step2

[Link]("Enter First No.: ");

float num=[Link]();//step3

[Link]("Enter Second No.: ");

double num1=[Link]();

[Link]("Enter Third No.: ");

int num2=[Link]();
double avg=(num+num1+num2)/3;

[Link]("Average of "+num+", "+num1+", "+num2+"and is: "+avg);

import [Link].*;

public class number

public static void main()

[Link]("\u000c");

Scanner Sc= new Scanner ([Link]);

[Link]("Enter your number");

int num=[Link]();

int r=num%100;

int q=num/100;

[Link]("Entered no is: "+num);

[Link]("Altered no. is: "+r+q);

public class returntype

{
public static void add(int a, int b)

[Link]("\u000c");//clears screen

int c;

c=a;

a=b;

b=c;

[Link]( a+ " "+b);

public class ascii

public static void main()

[Link]("\u000c");

[Link]("\u0905");

[Link]("\u0906");

[Link]("\u0907");

[Link]("\u0908");

[Link]("\u0909");

[Link]("\u0900");

[Link]("\u0910");

[Link]("\u0911");

[Link]("\u0912");
[Link]("\u0913");

public class name

public static void main()

[Link]("\u000c");

[Link]("My name is Shivansh ");

[Link]("I study in RYAN INTERNATIONAL SCHOOL, NASHIK");

public class area

public static void main()

[Link]("\u000c");

int side=26;

[Link]("Area of square is: "+side*side);

public class display


{

public static void main()

[Link]("\u000c");

[Link]("Hello\tWorld");

public class addition

public static void main()

[Link]("\u000c");

int a=12;

int b=19;

int c=a+b;

[Link]("Addition of "+a+" and "+b+" is "+c);

public class average0

public static void main()

{
[Link]("\u000c");

int mat= 99;

int sci= 96;

int com= 90;

String name= "Sanchita";

double avg= (mat+sci+com)/3;

[Link]("Name is "+name);

[Link]("Her average is "+avg);

/*WAP to accept roll no., grade,div, name and percentage of student

* Display all the details in tabular form

* Write in notebook

*/

import [Link].*;

public class student

public static void main()

Scanner sc=new Scanner([Link]);

int rollno, grade;

String name;

char div;

double per;
[Link]("Enter roll no.: ");

rollno=[Link]();

[Link]("Enter your grade");

grade=[Link]();

[Link]("Enter your name");

name=[Link]();

[Link]("Enter your division");

div=[Link]().charAt(0);

[Link]("Enter your percentage");

per=[Link]();

[Link](" Students Details ");

[Link]("----------------------------------------");

[Link]("Roll no. Grade Division Name Percentage");

[Link](" "+rollno+" \t"+grade+" \t "+div+"\t"+name+" "+per);

import [Link].*;

public class standard

public static void call (String name, int eng,int mat,int com,int sci,int sst)

double per= (eng+mat+com+sci+sst)*100/500;

[Link]("\u000c");

[Link]("These marks are of "+name);


[Link]("English: "+eng+"\nMaths: "+mat+"\nScience: "+sci+"\nSST: "+sst+"\nComputer:
"+com);

[Link]("Percentage is: "+per);

public class example

public static void main()

int a=2,b=4,c=10;

int x=((a+b)>c)?c:1000;

[Link]("value of x"+x);

/*WAP to accept using method call name,rno,marks of comp internal

* comp written find total marks in comp and

* print all details on seperate lines

*/
public class students

public void input(String name,int rollno,int internal,int written)

[Link]("\u000c");

int tot=internal+written;

[Link]("Name :"+name);

[Link]("Roll No. :"+rollno);

[Link]("Total Marks :"+tot);

public static void main()

students obj=new students();//object created

[Link]("Sanchita",35,100,98);

students obj1=new students();//object 2 created

[Link]("Shivansh",30,70,60);

students obj2=new students();//object created

[Link]("Chinu",26,80,75);//metod invoked

/*

*$*$*$

*$*$*$

*$*$*$
*/

public class pattern

public static void main()

[Link]("*$*$*$");

[Link]("*$*$*$");

[Link]("*$*$*$");

/**

* WAP to accept 2 no. using method call and print add,sub,multiply,div and mod

*/

public class project

public static void main(int a, int b)

[Link]("\u000c");

[Link]("Sum is "+(a+b));

[Link]("Subtraction is "+(a-b));

[Link]("Multiplication is "+(a*b));
[Link]("Division is "+(a/b));

[Link]("Modulous is "+(a%b));

/**

*WAP using ternary operator

*print result pass if marks>=35 else print fail

*/

public class project_2

public static void main(int marks)

[Link]("\u000c");

String result=(marks>=35)?"PASS":"FAIL";

[Link]("YOU ARE "+result);

public class ninety_four

public static void main()

int x=10;

[Link](x= x++ * 2 + 3 * --x);


}

//WAP to initialise values for l and b and calculate the area of rectangle.

public class area_1

public static void main()

[Link]("\u000c");

int l; // declaration

l = 15;// initialisation

int b = 20;

int area = l*b;//dynamic initialisation

[Link]("Area of rectangle with length 15 and breadth 20 is " + area);

//WAP to input values for l and b (using method call) and calculate the area of rectangle.

public class area_2

public static void main(int l, int b)

[Link]("\u000c");

int area = l*b;//dynamic initialisation

[Link]("Area of rectangle with length "+l+" and breadth "+b+" is " + area);
}

//WAP to input values for l and b (using scanner class) and calculate the area of rectangle.

import [Link].*;

public class area_3

public static void main()

[Link]("\u000c");

Scanner sc=new Scanner([Link]);

[Link]("Enter value for length: ");

int l= [Link]();

[Link]("Enter value for breadth: ");

int b= [Link]();

int area = l*b;//dynamic initialisation

[Link]("Area of rectangle with length "+l+" and breadth "+b+" is " + area);

You might also like