Random Numbers coderinme

Random Numbers

Write Java program to generate 5 random numbers b\w 1 to 100 and it should be not follow with decimal point.

import java.io.*;
public class Q1
{
public static void main(String[] args)
{
int i,n=0;
for(i=1;i<=5;i++)
{
float a=(float)Math.random();
n=(int)(a*100);
System.out.print(" "+n);
}
}
}

For more programs on Java, visit our Java Archives

Random Numbers

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.