Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Convert string_1 to upper case Convert string_2 to lower case Extract a valid su

ID: 3796318 • Letter: C

Question

Convert string_1 to upper case Convert string_2 to lower case Extract a valid sub-string of multiple characters from string_1. Separate your code into sections with proper in-line comments such as Write a java program (name it RandomNumbers) that generates random numbers as follows. Make sure to properly label your output for each part below and print the outputs on separate lines. As in the previous program, use the tab escape character to line-up the outputs after the labels. A random integer number between 30 and 50 (inclusive). A random integer number between 20 and -20 (inclusive) A random integer number between -20 and -60 (inclusive) A random floating - point number between 0.0 and 15.9999 (inclusive). Separate your code into section with proper in-line comments such as Write a java program(name it MathMethods) that uses the MATH class method to perform the following tasks. Make sure to properly label your output for each task and print the output on separate lines. Use the tab escape character to line-up the outputs after the labels. Prompt the user to enter a negative integer number and print out its absolute value. Prompt the user to enter a floating-point number representing an angle and print out the angle's cosine, sine, and tangent values. Prompt the user to enter a floating point number and print out both of its floor and ceiling values. Prompt the user to enter two floating-point numbers (say X and Y) and print out the value of X^Y (X is raised to the power of Y) Prompt the user to enter an integer number and print out its squareroot . Try that with both negative and positive inputs.

Explanation / Answer

Hi, Please find my implementation.

Please let me know in case of any issue.

import java.util.Random;

public class RandomNumbers {

  

   public static void main(String[] args) {

      

       Random random = new Random();

      

       /* NOTE: random number between min max : random.nextInt(max - min + 1) + min */

      

       //PART A : Generate random integer number between 30 and 50 (inclusive)

       int partA= random.nextInt(50-30 + 1) + 30;

       System.out.println("Part A: "+partA);

       //PART B : Generate random integer number between -20 and 20 (inclusive)

       int partB= random.nextInt(20 -(-20) + 1) + (-20);

       System.out.println("Part B: "+partB);

      

       //PART C : Generate random integer number between -20 and -60 (inclusive)

       int partC= random.nextInt((-20)-(-60) + 1) + (-60);

       System.out.println("Part C: "+partC);

      

       /* NOTE: random float number between min and max : rand.nextFloat() * (max - min) + min; */

  

       //PART D : Generate random floating point number between 0.0 and 15.9999 (inclusive)

       float partD= random.nextFloat() * (15.9999f - 0.0f) + 0.0f;

       System.out.println("Part D: "+partD);

   }

}

/*

Sample Output:

Part A: 34

Part B: -10

Part C: -54

Part D: 15.02563

*/