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

Java homework Programming in Java I (MIS 3339) Fall 2017- Page 1 of 1 Homework 2

ID: 3887458 • Letter: J

Question

Java homework

Programming in Java I (MIS 3339) Fall 2017- Page 1 of 1 Homework 2 This is an individual homework assignment. You may receive help from other class mates, but you may NOT copy their work. Copied work will be considered plagiarism and dealt with according to the syllabus and university policy Objective: For this assignment, you will demonstrate that you can properly manipulate Java's built-in Math and Random classes, create an algorithm to solve a common trigonometry problem, and use variable assignment and re-assignment statements to generate a partial exponential sequence. Description: Computer programs make extensive use of variable assignments and re assignments in conjunction with a variety of mathematical functions and expressions to solve common needs. You will create a Java program that generates the first 10 numbers in the 2 sequence (https:/en.wikipedia.org/wikiExponentiation), generates 3 random numbers and lastly computes the length of the 3d side of a triangle using the Pythagorean Theorem Assignment: Create a command-line Java class that performs the following o Output the first 10 numbers in the 2 number sequence Your program must use variable assignment & re-assignment or incrementers as necessary to compute the sequence and output the values via System.out print Do NOT simply write 10 numbers * System.out.print statement that just outputs the " . System.out.print("2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0, 1024.0'); not correct Generates a random integer between the numbers 0 (inclusive) and 100 (inclusive) Generates a random integer between 100 (inclusive) and 200 (exclusive) Generates a random double between 10.0 (inclusive) and 20.0 (exclusive) Given a triangle with 2 known side lengths, calculate the length of the 3rd side o o o The algorithm that you create should work for any given triangle side lengths, however you can casily check your results using the example results shown below in Table 1 " Use string concatenation to combine the computed answers with text to provide descriptive output o Your output should appear similar to that shown below in Table 1 Upload your JAVA code file(s) to the appropriate Blackboard assignment The first ten 2 to the nth 2.0,4.0, 80,16.0, 32.0, 64.0, 128.0. 256.0, 512.0, 1024.0. A random number between (inclusive) and 100 inclusive) is: 38 A random number between 100 (inclusive) and 200 (exclusive) i 137 A random number between 10.0 inclusive) and 20.0 (exlusve) is: 1584117656358075 For atriangle whose side A -3.0 and side H- 40, side Cis Table 1-Example Output power numbers are: to be 5.0

Explanation / Answer

import java.util.*;
import java.lang.*;

class command_line
{

public static void main (String[] args)
{

System.out.println("The first ten 2 to the nth power numbers are : ");
for(int i = 1;i<=10;i++)
System.out.print(Math.pow(2,i)+" ");//pow() function is used to compute 2 raise to power i
  
Random rand = new Random(); // generate random number object rand

int randomNum = (int )(Math.random() * 100+1);
System.out.println(" A random number between 0(inclusive) and 100(inclusive) is : "+ randomNum);
  
randomNum = (int )(Math.random() * 100 + 100);
System.out.println(" A random number between 100(inclusive) and 200(exclusive) is : "+ randomNum);
  
  
double randomNum1 = 10 + rand.nextDouble()*10;
System.out.println(" A random number between 10(inclusive) and 20(exclusive) is : "+ randomNum1);
  
  
System.out.println(" For a triangle whose side A is 3.0 and side B is 4.0 , side C is computed to be ");
  
double C = Math.sqrt(3*3 + 4*4); // pythagorean theorem sqrt(square(A) + square(B))
  
System.out.print(C);
}

}

output:

The first ten 2 to the nth power numbers are :
2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 1024.0

A random number between 0(inclusive) and 100(inclusive) is : 70

A random number between 100(inclusive) and 200(exclusive) is : 113

A random number between 10(inclusive) and 20(exclusive) is : 13.281545677793485

For a triangle whose side A is 3.0 and side B is 4.0 , side C is computed to be
5.0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote