Volume of Box coderinme Write a program to make use of a parameterized method inside a class. Take the following case: Create a class Box and define a method in this class which will return the volume of the box. Initialize two objects for your class and print out the volumes respectively. If box is of different sides then it forms a cuboid: Volume of a cuboid = length × breadth × height If box is of same sides then …

Home » Archives for October 2016

# Month: October 2016

Arithmetic Operations coderinme Let us now Create a package called “Arithmetic” that contains methods to deal all arithmetic operations. Also, write a program to use the package. addition () : a + b Sub () : a – b Mul () : a * b Div () : a / b Program: class Arithmetic { private double x,y; public Arithmetic(double a,double b) { x=a; y=b; } public double Addition() { return(x+y); } public double Sub() { return (x-y); } public …

Class Circle and Method coderinme Design a class Circle and implement the following methods: Define a circle method to compute its area Define a circle method to compute its perimeter Define a method that takes a given point represented by a pair of numbers and checks whether or not the point is inside the circle. The circle class needs to have instance variables to store the radius of the circle, and the x and y coordinates of the center. Add …

Employ Gross Salary coderinme In a small firm employee numbers are given in serial numerical order, that is 1, 2, 3 etc. write a menu driven program to perform following operations: a) Create a file of employee data with following information: Employee No, Name, Sex, Gross Salary. b) Append the data of a new employee joining the firm. c) If a given employee leaves, delete his record. d) If gross salary of a given employee increases, update the gross salary. …

OddAndEven object coderinme Write Java program involving two classes: OddAndEven and TestOddAndEven. OddAndEven and countOfEven both of type int parameter and increment countOfOdd, if the number is odd, else increment x, Number of Even : y”, where x and y are the values of the instance variables. The TestOddAndEven class first creates OddAndEven object, then in a loop, read a number and use it to call the addNumber method until the user enters Q. Finally, it prints the count of …

Intersection of Rectangles coderinme Overlapping or Intersection of Rectangles Suppose we construct two different rectangles of different measurement, now we we intersect these rectangles,or overlap them, we come across a new rectangle. The intersection method computes the intersection of two rectangles – that is, the rectangle that is formed by two overlapping rectangles: You call this method as follows: Rectangle r3 =r1.intersection(r2); Write a program that constructs two rectangle objects, prints them, and then prints their intersection. Program: import java.awt.Rectangle; …

Print Digits Individually coderinme Suppose a user enters a number 12345. Now we shall code to print each digit of the user given number in a separate line just like written below: 1 2 3 4 5 Write a Java program which reads a 4-digit number and prints the digits on separate lines. (Each digit is printed on one line). Program: import java.io.*; public class Q17 { public static void main(String[] args) throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Please …