You run a sunset dinner cruise. The maximum carrying capacity of the ship, SS Ru
ID: 3529602 • Letter: Y
Question
You run a sunset dinner cruise. The maximum carrying capacity of the ship, SS Russ T. Buckett, is 500 passengers (excluding the crew). You want to decide what would be the maximum profit before your negotiations with a client. The client may be able to bring up to the maximum number of passengers. Allow the user (that's you. the ship owner) to: Enter the minimum number of passengers to let on board Enter the initial ticket price Calculate the ticket price and profit for each group of 10 passengers above that minimum (i.e. from 200.210, 220. 230. etc.) Determine what was the maximum profit, the ticket price that generated that maximum profit and the number of passengers at that maximum profit You have agreed to lower the ticket price by 50 cents per each group of 10 additional passengers that the client brings to the ship. If the client has agreed to pay you S30.00 per person provided that a minimum of 200 people sign up for a moonlight dinner dance cruise then you agree to lower your price by 50 cents per ticket for EACH additional group of 10 people showing up over the minimum of 200. For example: You will incur a fixed cost of $2,500.00, no matter how many people show up. Your program should allow the following: Compute the ticket price and profit for each group of passengers starting at 200, 210, 220, 230, 240, 250,..., 490, 500). Determine the maximum PROFIT, the number of passengers needed to generate that profit, and the ticket price that will generate that profit. Allow the program user (...that's you) to enter the proposed initial ticket price and the minimum passengers. Calculate and display the number of passengers that the ship can carry to calculate the ticket prices and profit for each group of passengers (i.e. 200, 210, 220, 230, etc.). The loop will execute a different number of times during the execution depending on what that minimum was. User can execute this any number of times. Logic should ask user if they wish to quit or continue. You will be using some sort of loop to repeat the application possibly multiple times. Depending on the number of passengers and what ticket price was set. Have the logic also "tell you that this may be a bad deal". Algorithms needed: NP is the Number of Passengers TP is the Proposed Ticket Price MP is the Minimum Number of Passengers Cost of Ticket = TP - (((NP - MP)/10) * .5) Profit = (NP * Cost of Ticket) - 2500 Since you are "incrementing by 10 passengers", you might want to use some sort of a loop.Explanation / Answer
import java.util.*;
import java.lang.*;
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in = new Scanner(System.in);
System.out.println("Enter Minimum Number of passengers ");
int MP = in.nextInt();
System.out.println("Enter proposed ticket price. ");
double TP = in.nextDouble();
double ticket_cost = 0;
double profit = 0;
double max_profit = 0;
double max_profitable_ticket = 0;
int max_profitable_passengers = 0;
for(int NP = MP; NP<=500; NP = NP +10)
{
ticket_cost = TP - (((NP -MP)/10))*.5;
profit = NP*ticket_cost - 2500;
System.out.println(" for " + NP + " passengers ticket cost is " + ticket_cost);
System.out.println(" and profit generated is " + profit);
if(profit < 0)
{
System.out.println(" profit is " + profit + " -> this is bad deal ");
}
if(profit > max_profit)
{
max_profit = profit;
max_profitable_ticket = ticket_cost;
max_profitable_passengers = NP;
}
}
System.out.println(" ");
System.out.println(" ");
System.out.println("max profit occured is " + max_profit + " with " + " Passengers : " +
max_profitable_passengers + " and their ticket cost is " + max_profitable_ticket);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.