Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA I NEED TO FINISH UP THIS PROGRAM ITS DUE TONIGHT AT 12PM Serious HELP Please _ My Final Project My programs runs I am

JAVA

I NEED TO FINISH UP THIS PROGRAM ITS DUE TONIGHT AT 12PM

Serious HELP Please _ My Final Project

My programs runs I am just missing a few things

I Need help with number 2 and i have to use the queues class that i posted below.

*PLEASE READ BEFORE YOU ANSWER THANKS IN ADVANCED*

image text in transcribed

import java.util.*; import java.text.DecimalFormat; public class LemonadeStand { public static void main(String[] args) { //local constants double money = 100; double unitsOfLemons = 0; double unitsOfSugar = 0; double unitsOfIce = 0; double unitsOfWater = 0; double lemonCost = 1; double sugarCost = 0.25; double iceCost = 0.05; double waterCost = 0.05; //local variables double possibleCups; double lemonPurchase; double sugarPurchase; double icePurchase; double waterPurchase; double spoiled; int weather; int customers; double cupsSold; double profit; int seed; int water; Scanner scan = new Scanner(System.in); DecimalFormat dec = new DecimalFormat("#.00"); //********************************************************************************************// //get seed value from user for creating random number generator System.out.println("Please enter a number to randomize the game: "); seed = scan.nextInt(); Random rand = new Random(seed); //begin day loop for (int day = 1; day

public class LinkedQueueClass { //Definition of the node private QueueNode queueFront; //reference variable to the //first element of the queue private QueueNode queueRear; //reference variable to the //last element of the queue //default constructor public LinkedQueueClass() { queueFront = null; queueRear = null; }//end constructor //Method to initialize the queue to an empty state. //Postcondition: queueFront = null; queueRear = null public void initializeQueue() { queueFront = null; queueRear = null; }//end initializeQueue //Method to determine whether the queue is empty. //Postcondition: Returns true if the queue is empty; // otherwise, returns false. public boolean isEmptyQueue() { return (queueFront == null); }//end isEmptyQueue //Method to return the first element of the queue. //Precondition: The queue exists and is not empty. //Postcondition: If the queue is empty, the method throws // QueueUnderflowException; otherwise, // the value of the first element // of the queue is returned. public String front() throws QueueUnderflowException { if(isEmptyQueue()) throw new QueueUnderflowException(); else { return queueFront.getString(); } }//end front //Method to return the last element of the queue. //Precondition: The queue exists and is not empty. //Postcondition: If the queue is empty, the method throws // QueueUnderflowException; otherwise, // the value of the last element // of the queue is returned. public String back() throws QueueUnderflowException { if(isEmptyQueue()) throw new QueueUnderflowException(); return queueRear.getString(); } //Method to add queueElement to the queue. //Precondition: The queue exists. //Postcondition: The queue is changed and newNode // is added to the queue. public void addQueue(String newElement) { QueueNode newNode = new QueueNode(newElement); //create the node newNode.link = null; //initialize the link field to null if(queueFront == null) //if initially the queue is empty { queueFront = newNode; queueRear = newNode; } else //add newNode at the end { queueRear.link = newNode; queueRear = queueRear.link; } }//end addQueue //Method to remove the first element of the queue. //Precondition: The queue exists and is not empty. //Postcondition: The queue is changed and the first // element is removed from the queue. public void deleteQueue() throws QueueUnderflowException { if(isEmptyQueue()) throw new QueueUnderflowException(); queueFront = queueFront.link; //advance queueFront if(queueFront == null) //if after deletion the queue is queueRear = null; //empty, set queueRear to null } //end deleteQueue }//end Class public class QueueNode { String info; //Data type of Queue Node QueueNode link; //Reference to next node in queue //default constructor public QueueNode() { info = ""; } //constructor with a parameter public QueueNode(String data) { info = data; } //Method to set the value of the instance variable num. //Postcondition: info = data; public void setString(String data) { info = data; } //Method to return the value of the instance variable num. //Postcondition: The value of num is returned. public String getString() { return info; } public boolean equals(String otherElement) { return (info.equals(otherElement)); } public int compareTo(String otherElement) { return (info.compareTo(otherElement)); } public void setNext (QueueNode nextNode) //link to next node in Queue { //assign pointer to next node link = nextNode; }//end nextNode public QueueNode getNext() //get next link or go to the next node in Queue { //get the pointer return link; }//end getNext public String toString() { return String.valueOf(info); } } public class QueueException extends RuntimeException { public QueueException() { } public QueueException(String msg) { super(msg); } } public class QueueUnderflowException extends QueueException { public QueueUnderflowException() { super("Queue Underflow"); } public QueueUnderflowException(String msg) { super(msg); } } public class QueueOverflowException extends QueueException { public QueueOverflowException() { super("Queue Overflow"); } public QueueOverflowException(String msg) { super(msg); } }

Directions for the Lemonade Stand Game using Queues Create your very own lemonade stand and run a simulation for 30 days to try and make some money. 1. Start each day with a weather report. This is where you find out what kind of weather your day will have. The weather will change every day. Set up your weather reports so that some days it will rain some days will be hot and sunny, some days will be cloudy and cool. 2. Use a Queue structure to represent customers standing in line. The average number of customers will be 10 per hour. Establish your parameters so that the average number of customers per hour is dependent upon the weather. On rainy days, you will have a decrease in customers - with a random range from no customers up to 2 per hour, hot and sunny days you will have a significant increase in customers up to 10 per hour, and on cloudy and cool days you will have a mediocre amount of customers - up to 4 per hour Do you think people will want to stop and buy lemonade in the rain? Probably not, so you might not want to make any lemonade at all on those days. Some days it will be hot and sunny and on those days, you will want to make plenty of lemonade to sell. 3. Start your business with $100 in assets. You will have the following business expenses: a. Lemons i. Lemons will range in price from $1.00 each, 2 for a dollar, or 3 for a dollar. Use b. Sugar c. Ice d. Water one lemon per cu i. Sugar will cost either S.25 cents a cup or S.50 cents a cup. i. Ice will cost $.05 cents a cup or S.10 cents a cup. i. . Water will cost $.05 cents a cup Cups will cost $.02 cents a cup. Each sign will cost S.25. For each sign you purchase, your number of customers will e. Cups i. f. Advertising i. increase by 1% 4. You will have three parameters that affect vour business: cost per glass, advertising, charge per glass, a. How much it will cost you to make one glass of lemonade. Have this cost change everyday in terms of the cost of lemons, sugar, ice, and cups. Randomly generate the cost of each per day and then base how much you will buy of each on how much each costs. Decide how many glasses of lemonade to make for the day. Remember how much the COST PER GLASS i:s before you spend too much. After you have determined each of the parameters, begin your scenario You will have advertising expenses. This will be how much you pay for signs. Each sign costs 256. Determine each day whether you want to advertise and how many signs you want to purchase. Have the number of customers increase by 1% per sign Next you will decide how much to charge for each glass of lemonade. Be careful! People won't buy your lemonade if you charge too much. But remember, you must charge more then what it costs to make each glass to make any money at all. Have the weather be a factor irn how much you charge your customers b. c. Did your ASSETS go up? If so, you made money!! At the end of a day generate a statement that tells you how much you charged per glass, how many glasses you made, and how many you sold. Add up the expenses, which is the money you spent on signs and making lemonade. Your NET PROFIT is how much money you made that day. Keep track of your days in terms of which day of the month it is. Will you make more money on a weekend? Or perhaps you make more money during lunch time on a week day? These can be other factors to take into consideration You MUST use a queue structure for the customers standing in line! Remember you have 30 days of following the steps above to try and make a bunch of money! GOOD LUCK

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago