1)A class Called: RandomNumberGenerator that generate random numbers from 1 to 100

2)A class Test that tests the hierarchy in A) especially the getArea() and getVolume() methods. Use an object from the Random NumberGenerator class to generate your input test data.

View Answers

June 4, 2013 at 4:37 PM

hi friend,

Try the following code may this will be helpful for you.

RandomNumberGenerator.java

package net.roseindia.simpleExample; import java.util.Random; public class RandomNumberGenerator { Random random = new Random(); public int randomNumber() { int randumNum = random.nextInt(100-1+1)+1; return randumNum; } }

Area.java

package net.roseindia.simpleExample; abstract class Area { public abstract void getArea(); }

AreaOfRectangle.java

package net.roseindia.simpleExample; public class AreaOfRectangle extends Area { RandomNumberGenerator random = new RandomNumberGenerator(); int length = random.randomNumber(); int breadth = random.randomNumber(); @Override public void getArea() { System.out.println("Length Of Rectangle : "+length); System.out.println("Breadth Of Rectangle : "+breadth); int area = length*breadth; System.out.println("Area of Rectangle l*b = : "+area); } public static void main(String args[]) { AreaOfRectangle rectangle = new AreaOfRectangle(); rectangle.getArea(); } }

Related Tutorials/Questions & Answers:

Generate random numbers from 1 to 100 1)A class Called: RandomNumberGenerator that generate random numbers from 1 to 100 2)A class Test that tests... an object from the Random NumberGenerator class to generate your input test data

Generate Random Numbers hi,,, Please give me answer with example How do you generate random numbers within a given limit with actionscript... This function generate random numbers with in given limit

Advertisements

generate random numbers and display the largest Hi, I am using...; i++){ array[i] = r.nextInt(100) + 1; } int max = array[0... creates an array and fills it with random ints, prints the contents

How to generate a list of random numbers? Hi, How to generate a list of random numbers? I want code in scala programming language. Thanks ... of Scala programming and it generates random integer. Following program

How to generate a list of random numbers? Hi, How to generate a list of random numbers? I want code in scala programming language. Thanks ... of Scala programming and it generates random integer. Following program

How to generate a list of random numbers? Hi, How to generate a list of random numbers? I want code in scala programming language. Thanks ... of Scala programming and it generates random integer. Following program

Generate random number between two numbers in Scala Hi, How to Generate random number between two numbers in Scala? Thanks Hi, Following code can be used for generating random number in scala: val rand = new

Generate random number between two numbers in Scala Hi, How to Generate random number between two numbers in Scala? Thanks Hi, Following code can be used for generating random number in scala: val rand = new

Prime numbers in Java between 1 and 100 Hi, How to display prime numbers in java between 1 and 100? Thanks Hi, Prime numbers... which prints prime numbers between 1 and 100. Here is complete for printing prime

Generate array of random numbers You can generate a random number either...() but it is better to use Random class. If you want to generate a series of random numbers.... In this section, we are going to accept 10 numbers and display 5 numbers from them

Generate array of random numbers without repetition In the previous section, you have learnt how to generate an array of random numbers from the given array... created an application that will generate the array of random numbers without

How to list even numbers between 1 and 100? Hi, I Java to check if a number is even? How to list even numbers between 1 and 100? Thanks ... the numbers between 1 and 100 for (int i=1;i <=num ; i++){ if(i%2==0

Generate random numbers in Java - How to use the java.util.Random class... in Java which is used by developers to generate pseudo-random numbers in the Java... generate random numbers efficiently. But if you are using this class

print the sum of even number from 1 to 100 how to print the sum of even number from 1 to 100 using for loops? Thanks

random numbers hi.. i am creating a website and on feedback form to authenticate user i want to generate a random number on label.if user types that number correctly in textbox then he is allowed to submit feedback otherwise

five random numbers. If you are using java Math.random it will generate...How to generate random number in java In this section you will learn how to generate random number in java. Java API provide a random class

random numbers Hi I need some help with the code for the this program. This program should randomly choose a number between 1 and 1000... the computer has randomly chosen the number 759.] Guess my number! It's between 1 and 1000

multiply of 100 digits numbers multiplying 100 digits numbers to eachother

Random numbers hi, How to generate unique random numbers between range like(10 to 50) Hi friend, class RandomNumber { public static void main(String[] args) { //set the variable aNumber

random numbers write a program to accept 50 numbers and display 5 numbers randomly Hi Friend, Try the following code: import...(); System.out.println("Random numbers are: "); int random[]=new int[5]; for(int i=0;i

print 100 numbers using loops how to print from 1 to 100 using...{ public static void main(String[] args){ for(int i=1;i<=100;i... Numbers { public satic void main(string args[]_ { for(int a=1;a<

, The java.util.Random class can be used to generate the random numbers. Check the tutorial: Generate random numbers in Java. Thanks...How do I generate random number? In my Java program

Generating random numbers in a range with Java Generating random numbers in a range with Java

random numbers Hello i need this code to be modified for me to display the random numbers, but not twice or more. I mean i need a number...("Random numbers are: "); int random[]=new int[5]; for(int i=0;i Hi

Generate Random Integer Between Two Values in Scala Hi, I am working on the SCALA project and want to generate random integer between two numbers. How to Generate Random Integer Between Two Values in Scala? Thanks

Generate Random Integer Between Two Values in Scala Hi, I am working on the SCALA project and want to generate random integer between two numbers. How to Generate Random Integer Between Two Values in Scala? Thanks

generate random integer matrix in r Hi, I want to generate random integer matrix in r. What is easy code to generate random integer matrix in r? Thanks Hi, Following is the code for generating random integer

ModuleNotFoundError: No module named 'random_string_generate' Hi...: No module named 'random_string_generate' How to remove the ModuleNotFoundError: No module named 'random_string_generate' error? Thanks Hi

ModuleNotFoundError: No module named 'random_string_generate' Hi...: No module named 'random_string_generate' How to remove the ModuleNotFoundError: No module named 'random_string_generate' error? Thanks Hi

Default constructor generate two random equations Need to create a default constructor in a programmer defined class that generates a random question, addition or subtraction. And when adding the numbers must be random from 0-12

generating random numbers We would like to be able to predict... will restrict consideration to weights that are chosen from the following 21 values... predecessors. 1) {50,10,50,10,50,10,50,10,50,10,50,10} Returns: 0.0

how to generate random questions i am designing a test engine, i...]="Question No 1"; questionAr[1]="Question No 2"; questionAr[2]="Question..."; Random generator = new Random(); int r = generator.nextInt(questionAr.length

for your application. Random Number is the frequently used to generate numbers... understand and use the code to generate random numbers in your java...; In many places you need random numbers to fulfill your

; Random numbers are the numbers that are determined entirely by chance. User does not have any control over the working of random numbers...;CENTER"> Ramdom number from 10 to 100 : <FONT COLOR="

Sequence number to generate daily starting with 1 Sir, I am creating a bill report Application..I want to generate a sequence number for bill that is starting from 1.and if date changes the sequence number again starts with 1

pdf generate from jsp how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same

Prime Numbers from range how to find prime numbers in a given range...(); int index1=0; int index2=number.length()-1; char x...; if (index2-index1==0 || index2-index1==1) list.add(i); index1

a program that produces random permutations of the numbers 1 to 10. eg...Generating Random Numbers to Fill array. Java Beginner needing help! ... the permuted numbers. Make a second array and fill it with the numbers 1 to 10

J2ME Random Number In this application we are going to generate the random number using Random class. The Random class within the java.util package and we can use

random numbers between 1 to 100 in Java. Though i m new to Java, i have tried many... to generate the random number in Java Thanks in Advance...getting random number in java getting random number in java Hi

How to generate XML from XSD? Hi Experts, I have a xsd with me. I want to generate XML files based on the XSD with fields filled out from the database tables. Please Help me out

ModuleNotFoundError: No module named 'generate-changelog-from-releases' ...: ModuleNotFoundError: No module named 'generate-changelog-from-releases' How to remove the ModuleNotFoundError: No module named 'generate-changelog-from-releases'

read a positive real numbers from highest to lowest write a java program that will read a sequence of 10 positive real nos. entered by the user and will print the same numbers in sorted order from lowest to highest using arrays

; In this example we are discussing how to generate the random numbers... which we want to generate the random numbers, this method rounds the float value... random numbers by apply some mathematical operations onto them and display 10

how to generate the pdf report from jsp <%@page import="com.itextpdf.text.,com.itextpdf.text.pdf.,java.io.*;"%> </head> <... want to generate the pdf file from jsp page.I add the itext.jar to the libraries

to generate 1 random no public class TestRandom { public static void main(String... random no between 100 and 200 on loading and on clicking submit button it ives...[]){ Random r = new Random(); int start = 100, end = 200

Generate unicode malayalam PDF from JSP Hi, I want to generate... the same report to be saved as PDF in unicode malayalam font.I have tried to generate PDF reports using IText,but I dont know how to generate unicode malayalam

Pick Prime Numbers from the ArrayList Programmers mostly used ArrayList... integer values in the arraylist and from the arraylist we have to find the prime and non prime numbers separately. Here is the code: import java.util.

Find Numbers which are palindrome and prime In this section, you will learn how to find the numbers from 1 to 500 which are palindrome and prime. To compute...() of boolean type. Now the list contains all the numbers which are palindrome

Solving task 1 by 1 from bundle of task data Hello and namaste guys, i really need help here.i use ResultSet to query data from database. as we know... set.what should i do so that the solve code solve data 1 by 1?do i need to use

Ads