Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/* I am trying to run a java program that does the simulation from the picture below. Here's what I have so far but i

/* I am trying to run a java program that does the simulation from the picture below. Here's what I have so far but i got stuck. I need help running the program that allows me to simulate up to whatever number of days I enter like like 1,000,000 days for example. */ package; import java.util.Random; import java.util.Scanner;

public class { public static void main(String[] args) { int NUM_DAYS=0; //The number of days to simulate int NUM_BUY=0; //The number of news papers to buy each day double totalProfit=0;//Total profit double priceBuy=0.33; //The price of each paper to buy double priceSell=0.50;//The price of each paper to sell double priceRecycle=0.05;//The price of each paper to recycle int dayDemand; //Number of papers demanded for the day int randDayType, randGoodDay, randFairDay, randPoorDay; Random rand=new Random();//Create an Object of the Random class //that will be used to generate random integers Scanner scan=new Scanner(System.in);//Create an object for input from keyboard System.out.println("Enter the number of papers to buy and press the enter key: "); NUM_BUY=scan.nextInt();//Read and store the integer entered System.out.println("Enter the number of days to simulate and press the enter key:"); NUM_DAYS=scan.nextInt();//Read and store the integer entered System.out.println("This program simulates "+NUM_DAYS+ " days with "+NUM_BUY+" papers to buy each day."); for(int i=0; i=4 &&randGoodDay=9 &&randGoodDay=24 &&randGoodDay=44 &&randGoodDay=79 &&randGoodDay35 && randDayType=11 &&randFairDay=29 &&randFairDay=69 &&randFairDay=89 &&randFairDay=97 &&randFairDay

if(randPoorDay=45 &&randPoorDay=67 &&randPoorDay=83 &&randPoorDay=95 &&randPoorDaynumBuy) return numBuy*p-(dayDemand-numBuy)*p; return dayDemand*p+(numBuy-dayDemand)*(priceRecycle-priceBuy); }

} image text in transcribed

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

Step: 3

blur-text-image

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions