These questions need to be answered in java, thank you for your help! Write a me
ID: 3685253 • Letter: T
Question
These questions need to be answered in java, thank you for your help!
Write a method with the signature "int randomBetween(int low, int high)" that accepts two integer representing a range. The method must return a random integer in the specified range (inclusive). You may assume that the second parameter is greater than the first. Create array declarations for the following descriptions of arrays: 1. students' names for a class of 150 students 2. students' GPAs for a class of 40 students 3. last week's temperatures: 99 103 106 107 109 110 109 4. for each employee of the L&L; International Corporation: the employee number, hire date, and the amount of the last five raises.Explanation / Answer
Question 4:
import java.util.Random;
/**
* @author Srinivas Palli
*
*/
public class RandomGenerator {
public static void main(String[] args) {
RandomGenerator generator = new RandomGenerator();
System.out.println("Random Number between 10 and 100 :"
+ generator.randomBetween(10, 100));
System.out.println("Random Number between 100 and 250 :"
+ generator.randomBetween(100, 250));
}
int randomBetween(int low, int high) {
Random random = new Random();
int randomNum = random.nextInt((high - low) + 1) + low;
return randomNum;
}
}
OUTPUT:
Random Number between 10 and 100 :62
Random Number between 100 and 250 :215
Question 5:
1.
//student names to store 150
String studentName[]=new String[150];
2.
// student GPA to store 40 student
double studentGPA[] = new double[40];
3.
//last week temperature
int[] temperatures={99,103,106,107,109,110,109};
4.
class Employee{
int employeeNumber;
String hireData;
double last5Raises;
public int getEmployeeNumber() {
return employeeNumber;
}
public String getHireData() {
return hireData;
}
public double getLast5Raises() {
return last5Raises;
}
public void setEmployeeNumber(int employeeNumber) {
this.employeeNumber = employeeNumber;
}
public void setHireData(String hireData) {
this.hireData = hireData;
}
public void setLast5Raises(double last5Raises) {
this.last5Raises = last5Raises;
}
}
//Employee Array of objects
Employee employees[]=new Employee[10];
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.