# Operators in JAVA

#### Java : **Operators in JAVA** Program List

**Program [1]**

Write a program that calculates the number of miles that light will travel in 1000 days, which illustrates the use of long integer.

**Program [2]**

Create a program that will generate b bill at McDonald’s for four vegetable burgers (@Rs 45 per vegetable Burger) and three vegetable McPuffs(@Rs 25 per vegetable McPuff). There is a special Independence Day discount of Rs 50 on the final bill amount.

**Program [3]**

Write a program to find the sum and difference between 25 and 16 using variables in different
lines.

**Program [4]**

Write a program to average of 36,45 and 53 using variables of adequate data type.

**Program [5]**

Write a program to input the Principal, Rate and Time for a certain amount of money and
print the Simple Interest.

**Program [6]**

Write a program to input the length and breadth of a rectangle and find its area and perimeter.

Note:

Area of a rectangle=length*breadth

Perimeter of a rectangle=2*(length+breadth)

**Program [7]**

Write a java program to accept the radius and height of cone and calculate the volume of a cone.

**Program [8]**

Write a program to initialize three int variables a, b and c with 234, 456 and 712 and store the sum of the last digits of the variables into d and display it.

**Program [9]**

Write a program to input five integers and find their average.

**Program [10]**

Write a program to input the Principal, Rate and Time for a certain amount of money and print the Simple Interest.

**Program [11]**

Write a program to input the length and breadth of a rectangle and find its area and perimeter.

Note: Area of a rectangle=length*breadth

Perimeter of a rectangle=2*(length+breadth)

**Program [12]**

Write a program to input the radius of a circle and find its area and perimeter.

Note: Area of a circle=22/7* radius2

Circumference of a circle= 2 * 22/7 * radius

**Program [13]**

Write a program to input the length, breadth and height of a cuboid and find its Volume and Total Surface Area.

Note: Volume of a cuboid= length*breadth*height

Total Surface Area=2*(length*breadth+breadth*height+height*length)

**Program [14]**

Write a program to input the radius and height of a cylinder and find its volume and total surface area.

Note: Total Surface Area=22 + 2h

Volume=2h

**Program [15]**

Write a program to input the temperature in Fahrenheit and change it to Celsius.

Note: The relation between Fahrenheit and Celsius is given by the formula:

Where C=Celsius and F=Fahrenheit

**Program [16]**

Write a program to input time in seconds and display the time broken up as hours, minutes and seconds.

For Example:

INPUT: Enter Time in Seconds: 4326

OUTPUT:

Time in hours:1

Time in minutes:12

Time in seconds:6

**Program [17]**

Write a program to input a floating point number and round it off to the nearest integer.

For Example:

INPUT: Enter a floating point number: 12.3

OUTPUT: Rounded off to nearest integer:12

INPUT: Enter a floating point number: 14.5

OUTPUT: Rounded off to two places of decimal:15

**Program [18]**

Write a program to input two integers (say a and b) and interchange their values and display the result.

For Example:

INPUT: Enter two integers: 15 36

OUTPUT:

Before interchange: a=15 and b=36

After interchange: a=36 and b=15

Please note that you can take just one variable other than a and b for interchanging.

**Program [19]**

Write a program to input the time in hours, minutes and seconds and print it in seconds.

For Example:

INPUT: Enter time in hours:

1

Enter time in minutes:

12

Enter time in seconds:

6

OUTPUT:

Time in seconds:4326

**Program [20]**

Write a program to input three integers and find their sum, without using the mathematical operator +.

**Program [21]**

Write a program to input the Basic Pay of an employee and find the gross pay of the employee for the following allowances and deductions.

Dearness Allowance = 25% of Basic Pay

House Rent Allowance=15% of Basic Pay

Provident Fund=8.33% of Basic Pay

Net Pay=Basic Pay + Dearness Allowance + House Rent Allowance

Gross Pay= Net Pay – Provident Fund

**Program [22]**

Write a program to input an integer and if positive change it to negative and if negative change it to positive.

INPUT: Enter an integer: 12

OUTPUT: Sign changed:-12

INPUT: Enter an integer: -14

OUTPUT: Sign changed: 14

**Program [23]**

If the marks obtained by a student in five different subjects are input through the keyboard, write a program to find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100.

**Program [24]**

If the total selling price of 15 items and the total profit earned on them is input through the

keyboard, write a program to find the cost price of one item.

**Program [25]**

Write a program to input the area of a square and find its perimeter.

**Program [26]**

Write a program to input the length and breadth of a rectangle and find its diagonal

**Program [27]**

Write a program that outputs the results of the following evaluations based on the number entered by the user.

i. Cube root of the number

ii. Absolute value of the number

iii. Square root of the number

iv. Random numbers between 0 and 1.

**Program [28]**

Write a program to input the radius of a circle and find its area and circumference.

**Program [29]**

Write a program to input three integers and find the sum of their cube roots.

**Program [30]**

Write a program using ternary operator to check whether 27 is a multiple of 3 or not.

**Program [31]**

Write a program to input the area of a square and find its perimeter.

**Program [32]**

Write a program to input the length and breadth of a rectangle and find its diagonal.