Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with Java coding Stop the Stranger Insects We used to have very clean classroom. However, due to the unusual weather this year, some

Need help with Java coding

image text in transcribed

image text in transcribed

image text in transcribed

Stop the Stranger Insects We used to have very clean classroom. However, due to the unusual weather this year, some strange insects (we call them Java) were spotted in this room (do not be scared, they do nothing harmful, except disgusting). Female Java can give birth to about 30 baby Java each week. These mature quickly, and within a week can have litters of their own. And so, a few weeks later, Java were overrunning the classroom and everyone feel disgusting. One of our students finds a special way to kill these insects by writing java program. His program kills the insects as follows: It assumes there are E female Java and E male Java in a week, his program kills a percentage p of all Java, males and females in equal proportion (if after this slaughter you end up with 30.7 males and 32.8 females, round these down). It assumes that every surviving female will give birth to R baby Java within a week, and if R is odd, the odd baby Java will be a female. These Java will reach reproduction age by next week and will be ready to reproduce. Ultimately, we would like to be able to enter E, p, and R parameters into the model, and get an answer of how many Java are expected to be alive in X weeks from the start of the model. For example, if there were 100 female and 100 male Java in the week 1. the query for week one will return 200, no matter what p and R values are. If the query is for week 2, and the parameters are p=50, R=9, there will be 50 females and 50 males surviving into week 2, and each of those 50 females will bear 5 female baby Java and 4 male baby Java that week. 50 by next week, there will be 550 Java: 300 females and 250 males. In week 3, 150 surviving female Java will again bear 5 female and 4 male baby Java to add to the population. A sample solution is provided for testing. lnput: Input consists of a number of n (n  

data.txt

4 100 50 9 1 100 50 9 2 100 50 9 3 100 50 9 8

InsectJavaSol.java

import java.util.Scanner; import java.io.*;

public class InsectJavaSol{ public static void main(String[] args) throws FileNotFoundException{

Scanner input=new Scanner(new File(args[0])); int size=input.nextInt(); for(int i=0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions

Question

Describe the Fed's monetary policy response to the credit crisis.

Answered: 1 week ago

Question

How flying airoplane?

Answered: 1 week ago

Question

4. I can tell when team members dont mean what they say.

Answered: 1 week ago