Question
/* 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 if(randPoorDay=45 &&randPoorDay=67 &&randPoorDay=83 &&randPoorDay=95 &&randPoorDaynumBuy) return numBuy*p-(dayDemand-numBuy)*p; return dayDemand*p+(numBuy-dayDemand)*(priceRecycle-priceBuy); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started