Sale!

Lab Tutorial #1 To print ‘Bennett University’ on screen.

Original price was: $35.00.Current price is: $30.00.

Category:
5/5 - (1 vote)

Lab Tutorial #1
1) Objective: To print ‘Bennett University’ on screen.
Problem Statement:- Write a Java program to print ‘Bennett University’ on screen and then print
CSE on a separate line.
Code:-
package demo1;
public class Exercise1 {
public static void main(String[] args) {
System.out.println(“Bennett university”);
System.out.println(“\nCSE”);
}
}
Screenshot:-
Explanation:- The first line
public class Exercise1 {
declares a class called Exercise1. (Almost) everything in Java is contained in something called a class.
The second line
public static void main( String[] args ) {
declares a method called main(String[]). Most of the actual code in Java is found within methods.
Methods are one of the elements of classes. This particular method is executed when the Exercise1
class is executed .Note the String[] args. This means that the “arguments” will be passed into the main
method – essentially, within this method, you can edit and see arguments.
The third line
System.out.println(“Bennett university”);
does pretty much what you think it does: it writes “Bennett university” to your screen. println
means to print the string (text) provided and then add a line break (like the enter key).
2) Objective: To find the sum of two number using arithmetic operators.
Problem Statement:- Write a Java program to print the sum of two numbers.
Code:-
package demo1;
public class Excercise2 {
public static void main(String[] args) {
System.out.println(24+26);
}
}
Screenshot:-
Explanation:-
The line
System.out.println(24+26);
does pretty much what you think it does: it writes addition of two numbers to your screen. println means
to print the string (text) provided.
3) Objective: To find the division of two number using arithmetic operators.
Problem Statement:- Write a Java program to divide two numbers and print on the screen.
Code:-
package demo1;
public class Exercise3 {
public static void main(String[] args) {
System.out.println(60/3);
}
}
Screenshot:-
Explanation:-
The line
System.out.println(60/3);
writes division of two numbers to your screen. println means to print the string (text) provided.
Lab Practice
4) Objective: To find the output of the given data using arithmetic operators.
Problem Statement:- Write a Java program to print the result of the following operations.
Test Data:
a. -5 + 8 * 6
b. (55+9) % 9
c. 20 + -3*5 / 8
d. 5 + 15 / 3 * 2 – 8 % 3.
5) Objective: Find the product of two numbers taken by user input.
Problem Statement:- Write a Java program that takes two numbers and display the product of
two numbers.
Test Data:
a=10
b=5
6) Objective: To find the multiplication table up-to 10 of a given number.
Problem Statement:- Write a Java program that takes a number and prints its multiplication table
up-to 10
Test Data:
a=10
7) Objective: To find the sum (addition), multiply, subtract, divide and remainder of two number
using arithmetic operators.
Problem Statement:- Write a Java program to print the sum (addition), multiply, subtract, divide
and remainder of two numbers.
Test Data:
a=10
b=5
8) Objective: To find the specified expressions using arithmetic operators.
Problem Statement:- Write a Java program to compute the specified expressions and print the
output.
Test Data:
((25.5 * 3.5 – 3.5 * 3.5) / (40.5 – 4.5)).
9) Objective: To find the area and perimeter of a circle.
Problem Statement:- Write a Java program to print the area and perimeter of a circle.
Test Data:
Radius = 7.5
Note:
Area = pi * r*r
Perimeter = 2 * pi * r
Where pi = 3.14
10) Objective: To find the average of three numbers.
Problem Statement:- Write a Java program that takes three numbers to calculate and print the
average of the numbers.
Test Data:
a=10
b=5
c=3
11) Objective: Find the values using java operators.
Problem Statement:- What will be the output of following program ?
class Opr
{
public static void main(String args[])
{
int x=5,y;
y= ++x + x++ + –x;
System.out.println(x + “,” + y);
}
}

Reviews

There are no reviews yet.

Be the first to review “Lab Tutorial #1 To print ‘Bennett University’ on screen.”

Your email address will not be published. Required fields are marked *

Scroll to Top