Write a program named program52py that uses main and a void

Write a program named program52.py that uses main and a void function named numbers that takes no arguments and does not return anything. The numbers function generates 5 random integers, each greater than 10 and less than 30 (duplicates are okay), and prints them all on one line separated by spaces. A loop is required for this, and the loop should also total up the integers so the sum can be displayed when the loop ends. The main function should call the numbers function.
SAMPLE OUTPUT
12 24 16 21 17
The total is 90

Solution

import java.util.Random;
class program52y
{
static void numbers()
{
int Low = 11;
int High = 29;
int Result,total=0;
Random r = new Random();
for(int i=0;i<5;i++)
{
Result = r.nextInt(High-Low) + Low;
System.out.print(\" \"+Result);
total=total+Result;
}
System.out.println();
System.out.println(\"The total is \"+total);
}
public static void main (String args[])
{

numbers();

}
}

Write a program named program52.py that uses main and a void function named numbers that takes no arguments and does not return anything. The numbers function g

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site