1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
satela [25.4K]
3 years ago
7

Question 2 In this question you are asked to calculate probabilties for the discrete uniform and exponential distribution. Make

changes to H3_Q2.java to accomplish the following tasks. a. Print a menu to the screen asking the user to either type the number 1 to choose "discrete uniform" or the number 2 to choose "exponential". The tool should print out an error message and exit if the user types in anything other than one of those two numbers. b. If the user selects discrete uniform, the program should request a lower bound a, an upper bound b and value of x from the user. Your code should check that all values are integers and that the upper bound is greater than the lower bound. The code should also check that a ≤ x ≤ b. c. If the user selects exponential then the program should request a value of λ and x. Your should check that both values are doubles and that x > 0. d. Using the distribution chosen by the user, calculate P(X = x) and P(X ≤ x) and display the results to the screen with appropriate labels.
Computers and Technology
1 answer:
sasho [114]3 years ago
7 0

Answer:

Hi there! The question is asking to make changes to the H3_Q2.java program however there is no such program attached. Nevertheless, the requirements in the question can be addressed in a new H3_Q2.java program that i've listed below.

Explanation:

We can use the Scanner util in Java for prompting user input. The method nextInt() and nextDouble() allow only values of types "int" and "double" respectively. I have used the "switch" statement to direct the program based on user selection of menu item. The checks are printed with the "System.out.println" command and the program exits in case of error or invalid input. Finally, the calculation of probability simply requires you to replace the comment with the formula for the probability calculation based on the method chosen.

H3_Q2.java

import java.util.Scanner;

public class H3_Q2 {

 public static void main(String args[]) {

   // print main menu for user selection

   System.out.println("Please type 1 to select 'discrete uniform' or 2 to select 'exponential'");

   Scanner scan = new Scanner(System.in);

   int selection = scan.nextInt();

   switch(selection) {

     case 1:

       // discrete uniform

       System.out.println("Please enter a lower bound value a: ");

       int a = scan.nextInt();

       System.out.println("Please enter a upper bound value b: ");

       int b = scan.nextInt();

       System.out.println("Please enter a value x: ");

       int x = scan.nextInt();

       if (b <= a) {

         System.out.println("The upper bound value b should be greater than the lower bound value a");

         System.exit(0);

       }

       if (a > x) {

         System.out.println("The value x should be greater than the lower bound value b");

         System.exit(0);

       }

       if (b < x) {

         System.out.println("The value x should be greater than the lower bound value b");

         System.exit(0);

       }

       break;

     case 2:

       // exponential

       System.out.println("Please enter a lambda value for exponential: ");

       double lambda = scan.nextDouble();

       System.out.println("Please enter a value x: ");

       double d_x = scan.nextDouble();

       if (d_x <= 0.0) {

         System.out.println("The value x should be greater than 0");

         break;

       } else {

         // calculate P(X = x) and P(X ≤ x)

         // result = calculateExponential()

         System.out.println("The calculation for the exponential method given the lambda value " + lambda + " and the value of x " + d_x + " is: ");

       }

       break;

     default:

       System.out.println("Invalid input. Exiting..");

       break;

   }

 }

}

You might be interested in
When creating envelopes, how will you adjust the layout?
Burka [1]
It D because I hade this too so it is D
4 0
3 years ago
Read 2 more answers
Change the quick style gallery display
OverLord2011 [107]

Answer:

wdym?

Explanation:

5 0
2 years ago
Given positive integer numinsects, write a while loop that prints that number doubled without reaching 100. follow each number w
hichkok12 [17]
Hi,

the program is as follows
___________________________________________________________


import java.io.*;
class doubleval

  {
     public static void main()throws IOException   
     {

       DataInputStream dt=new DataInputStream(System.in); 

System.out.println("Enter NUMBER WHOSE DOUBLE U WANT TO                                           PRINT");       
            int n=Integer.parseInt(dt.readLine()); 

                  for(int i=n;i<=100;i=2*i)       
                    {           
                         System.out.println(i);       
                            }   
            }
}


           
3 0
3 years ago
In Python please.
Mazyrski [523]

Answer:

I dont know a lot about that but i know how to skeeo, i am reallyu good at sleeping.

Explanation:

7 0
3 years ago
HELP ASAP!!! 100 POINTS
malfutka [58]

Answer:

Below.

Explanation:

Up until a few weeks ago, I too was not aware of the extremely rich and entertaining variety of anime that existed. My first encounter with anime (outside Saturday morning cartoons) was when I was about nine years old. My mom took my siblings and I to see the Hayao Miyazaki film “Spirited Away.” At the time, I didn’t enjoy it at all. I thought it was boring, confusing, weird and creepy. Why? Because I was a child, and “Spirited Away” is not really a children’s film. Like many anime feature films, it is an experience better appreciated by mature viewers.

That isn’t to say that anime shouldn’t be viewed by children at all. If kids grow up watching anime, that’s fine. The problem for many kids is that they are raised on American animation with simple plots, flat characters and cheap comic relief. Then, when they encounter a Japanese animation with complex character development, deep themes, subtle dialogue and thought-provoking stories, they find it boring, as I did with “Spirited Away.”

In the course of the last several weeks, however, I have gone on a journey to discover some of the best that anime has to offer. As a student, I don’t have time to devote to an ongoing anime series, so this article will deal exclusively with feature films.

Going into this movie marathon, I predicted that I would gain a better appreciation for anime. But I had no idea how powerful and entertaining these films would be. There wasn’t one that I disliked, and many of them instantly joined my list of all-time favorite movies as soon as the credits rolled. All these movies featured not only beautiful animation, but also interesting and authentic characters, as well as expertly crafted narratives.

One of the misconceptions about anime is that it all looks the same. This couldn’t be further from the truth. Although anime as a genre is easily recognizable, there is a wide variety of styles and techniques that can give each film a unique look and feel.

Take, for example, “The Tale of the Princess Kaguya.” The film is an adaptation of a Japanese folktale. The studio opted to go with a raw animation style, with lots of watercolors and negative space, in order to invoke the aesthetic of an ancient scroll. It’s a very minimalist style, but it works beautifully, and it allows the director to portray the story in a way that wouldn’t be possible with CGI animation.

In one scene, a character grows increasingly upset, and as she does, the animation itself becomes more and more wild and untamed until it eventually devolves into a mess of scribbles. Very few films are able to so successfully intertwine the content of their film with the form in which they present it.

A lot of people might say they prefer American animation because “it looks more realistic.” In Japanese animation, they say, the characters all have silly, exaggerated faces and features. Really? Let’s do a side-by-side comparison.

These two films, “When Marnie Was There” and “Frozen,” came out within one year of each other. Frozen was one of the most popular American animated films in years. “When Marnie Was There” is (maybe) the last film to be produced by anime legends Studio Ghibli.

Looking at the two, which is more realistic? Well, it depends on what you mean by the word ‘realistic.’ If realistic to you means how close an image comes to being photo-realistic (indistinguishable from real life) then obviously “Frozen” is the more realistic of the two. On the other hand, I look at this and see one image that was made by a computer program (with some human help) and another image that appears to have been drawn by hand. For me, at least, the image on the right has a human quality to it that makes it much more “real” than the image on the left, which can easily be reduced to a bunch of ones and zeroes.

Don’t get me wrong. I enjoy Disney and Pixar movies as much as the next guy. But to dismiss anime for not “keeping up” with American animation just doesn’t make sense. Japan hasn’t undertaken the quest for the unattainable photo-realism, not because they’re incapable, but because they know that traditional animation as an art form doesn’t need to wholly rely on computers to be beautiful and engaging.

A common trend amongst all the anime films I watched is that the characters are believable. They do things that normal, everyday people would do. They say things that real people do. Their actions and choices make sense. And because they are so believable, they become relatable. As the movies progress, you really feel a connection with these characters.

7 0
3 years ago
Read 2 more answers
Other questions:
  • DSL technology is less efficient for service providers in the United States because many of their customers live in less-densely
    11·1 answer
  • The box plot represents this data set. {16, 16, 16, 18, 18, 20, 24, 28, 30, 34} What value does the letter A represent on the bo
    8·2 answers
  • An automated search feature used by search engines to find results that match your search terms is called a spider or ?
    5·1 answer
  • What is the best kernel synchronization solution on multicore systems when a lock is held for brief periods ?
    14·1 answer
  • Using existing algorithms as building blocks for new algorithms has all the following benefits EXCEPT
    12·1 answer
  • Write a python program that should determine from the range you choose to enter :
    9·1 answer
  • What is the school wifi password trying to do my class work in school on different devices.
    9·1 answer
  • What should you do if an online friend asked to meet you after school? <br>ᵖˡˢˢˢˢ...​
    13·2 answers
  • Abby has received a request for a data set of actual data for testing a new app that is being developed. She does not want the s
    13·1 answer
  • I want the answer of this task ( using prolog language ) ASAP because the deadline is tomorrow. Please help :"
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!