0% found this document useful (0 votes)
127 views9 pages

Lab Report

The document contains 4 lab reports describing programming tasks and solutions. Lab 1 involves writing a program to print a table up to 50 times using a for loop. Lab 2 creates a Calculator class with methods for addition and multiplication. Lab 3 overloads the Calculator methods and passes parameters using a constructor. Lab 4 creates a Teacher class and subclass for a physics teacher and calls methods to output details.

Uploaded by

Bilal Satti
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)
127 views9 pages

Lab Report

The document contains 4 lab reports describing programming tasks and solutions. Lab 1 involves writing a program to print a table up to 50 times using a for loop. Lab 2 creates a Calculator class with methods for addition and multiplication. Lab 3 overloads the Calculator methods and passes parameters using a constructor. Lab 4 creates a Teacher class and subclass for a physics teacher and calls methods to output details.

Uploaded by

Bilal Satti
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
You are on page 1/ 9

LAB REPORT

LAB #01
TASK #01:-
Description
Write a program to input a table and it's limit by the user and print it's table using for llop for 50
times.

package tablee;

/**

* @author satti

*/

import java.util.Scanner;

public class Tablee {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

int n;

System.out.println("enter number ");

Scanner in=new Scanner(System.in);

n=in.nextInt();

for (int i=1; i<=50; i++)

int a;

a=n*i;

System.out.println(n+"*"+i+"="+a);

}
LAB REPORT

}
LAB REPORT

LAB #02
TASK #01:-
Description
Create a class calculator with two variables a constructor with no parameter and two functions for
add and multiply. Create class testapp with a main function and create object of calculator class to
call function.

package calculator;

/**

* @author satti

*/

import java.util.Scanner;

class calculat{

int a,b;

int sum;

int product;

calculat () {

void sum () {

sum=a+b;

System.out.println("sum of number="+sum);

void product () {

product=a*b;

System.out.println("product of number="+product);

}
LAB REPORT

public class Calculator {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

Scanner in=new Scanner (System.in);

calculat obj= new calculat ();

System.out.println("enter first number");

obj.a= in.nextInt();

System.out.println("enter second number");

obj.b= in.nextInt();

obj.sum();

obj.product();

// TODO code application logic here

}
LAB REPORT

LAB #03
TASK #01
Description
Create a class calculator with two variables a constructor with no parameter and two overloaded
functions for add and multiply. Also call functions using math class Create class testapp with a
main function and create object of calculator class to call function.

package OveloadConstructor;

/**

* @author satti

*/

import java.util.Scanner;

class calculat{

int a,b;

int sum;

int product;

calculat () {

calculat(int AB, int CD) {

AB=a;

CD=b;

}
LAB REPORT

void sum () {

sum=a+b;

System.out.println("sum of number="+sum);

void product () {

product=a*b;

System.out.println("product of number="+product);

public class OveloadConstructor {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

Scanner in=new Scanner (System.in);

calculat obj= new calculat ();

System.out.println("enter first number");

obj.a= in.nextInt();

System.out.println("enter second number");

obj.b= in.nextInt();

obj.sum();

obj.product();

// TODO code application logic here

}
LAB REPORT
LAB REPORT

LAB #04
TASK #01
/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package teachers;

/**

* @author satti

*/class Teacher{

String designation;

String college;

void work () {

System.out.println("he is a teacher");

class physicsteacher extends Teacher {

public class Teachers {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

physicsteacher obj=new physicsteacher ();


LAB REPORT

obj.designation="he is a physics teacher";

obj.college="he teaches in NUML";

obj.work();

System.out.println(obj.designation);

System.out.println(obj.college);

You might also like