0% found this document useful (0 votes)
134 views2 pages

Lab #1: Operators and Expressions

The document outlines 7 labs covering programming concepts like operators, expressions, conditional statements, loops, arrays, sorting, classes, methods, interfaces, constructors and overloading methods. Lab 1 involves programs to convert temperatures, calculate areas and percentages. Lab 2 covers even/odd, maximum of 2 numbers and grade conversion. Lab 3 includes programs for character counting, Fibonacci, prime checking and perfect numbers. Lab 4 focuses on arrays for mean, mode, binary to decimal and matrix operations. Lab 5 covers sorting in ascending order and dictionary order. Labs 6 and 7 involve creating classes and methods to test primality, calculate student results, perform math operations on numbers, create a bank account class implementing an interface and overload constructors and methods

Uploaded by

Anjali Pokhrel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
134 views2 pages

Lab #1: Operators and Expressions

The document outlines 7 labs covering programming concepts like operators, expressions, conditional statements, loops, arrays, sorting, classes, methods, interfaces, constructors and overloading methods. Lab 1 involves programs to convert temperatures, calculate areas and percentages. Lab 2 covers even/odd, maximum of 2 numbers and grade conversion. Lab 3 includes programs for character counting, Fibonacci, prime checking and perfect numbers. Lab 4 focuses on arrays for mean, mode, binary to decimal and matrix operations. Lab 5 covers sorting in ascending order and dictionary order. Labs 6 and 7 involve creating classes and methods to test primality, calculate student results, perform math operations on numbers, create a bank account class implementing an interface and overload constructors and methods

Uploaded by

Anjali Pokhrel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

Lab #1: Operators and expressions

1. Write a program to convert centigrade to Fahrenheit. [F = 9/5 * C + 32]


2. Write a program that calculates the area of a circle and circumference.
3. Write a program that calculates the area of a triangle.
4. Write a program that reads the marks in each subject and calculates the
percentage.
Lab #2: Conditional Statements
1. Write a program that reads a number and identifies whether the given
number is even or odd.
2. Write a program to find the largest number among two numbers
3. Write a program to read the mark of a subject and prints the equivalent
grade.
Lab #3: Loop
1. Write a program to read a sentence and counts the total number of character
(excluding space) using while loop.
2. Write a program to generate Fibonacci number using do while loop.
3. Write a program to read number and identify whether the given number is a
prime number or not.
4. Write a program to identify whether the given number is a perfect number or
not. 28 is a perfect number.
5. Write a program to calculate the factorial of a given number.
Lab #4: Array
1. Write a program to store ‘n’ numbers in a one-dimensional array and
calculate its mean and mode.
2. Write a program to convert a user given binary number to decimal.
3. Write a program to evaluate transpose of n by n matrix.
4. Write a program for matrix addition. The user will provide dimensions and
elements of both matrices.
Lab #5: Sorting
1. Write a program to arrange the numbers (array) in ascending order using
bubble sort.
2. Write a program which asks the user to input ‘n’ words. Now Display the
words in dictionary order.
Lab #6: Classes and Methods
(All the programs below should be carried out by creating class and implementing the class with objects)

1. Write a program to test whether the given number is prime or not.


2. Write a program in java to input name of student and marks obtained in 5 subjects.
Calculate total, percentage and result.
3. Write a program in java to input two numbers and calculate sum, difference, product
and quotient.

Lab # 7: More on interfaces, constructors and methods


1. Write a program of a bank account with class Bank account which implements interface
bank.
2. Write a Java Program to define a class, describe its constructor, overload the
Constructors and instantiate its object.
3. Write a Java Program to define a class, define instance methods for setting and
retrieving values of instance variables and instantiate its object.
4. Write a Java Program to define a class, define instance methods and overload them and
use them for dynamic method invocation.

You might also like