シネマがショーごとに5ドルと平均100チケットを販売する場合、1人あたりの費用は2ドルです。価格が0.25ドル下がるごとに、チケットの売り上げは30増加し、1人あたりのコストは0.10ドル増加します。販売されたチケットの数、1人当たりの費用、総収入、総費用、純利益を示す価格表($ 5から$ 3まで)を表示します。最大利益を示します。最大利益計算機Java
私はこの問題に近づくのに苦労しており、私は正しい方向に導かれる助けを求めています。私はコーディングがあまり良くなく、実践のためにこれをやっています。私は配列を使って自分の知識を使用しようとしましたが、無駄です。ヘルプをよろしくお願いいたします。
/* If a cinema sells tickets for $5 and averages 100 tickets sold per show,
the cost per person is $2.
For each reduction in price of $0.25,
the number of tickets sold increases by 30 and the cost per person increases by $0.10.
Print a table showing the price (ranging from $5 to $3,) the number of tickets sold,
cost per person, gross revenue, total cost, net profit. Indicate the maximum profit.
*/
import java.util.*;
import java.io.*;
public class MaxProfitCalc {
public static void main(String[] args) {
for (double ticketCost = 5.0; ticketCost >= 3.0; ticketCost-=0.25) {
System.out.printf("Ticket cost is: " + "%.2f\n", ticketCost);
}
for (double costPerPerson = 2.0; costPerPerson <= 2.80; costPerPerson+=0.10) {
System.out.printf("Cost per person is: " + "%.2f\n", costPerPerson);
}
for (int ticketSold = 100; ticketSold <= 340; ticketSold+=30) {
System.out.println("Amount of tickets sold: " + ticketSold);
}
}
}
EDIT私は今、それが数字を計算する問題であり、番号を印刷する方法を考え出しました。最大利益、総収入、および総費用を把握するために最も高い数字にアクセスする方法はありますか?配列を作成する必要がありますか、forループから数値を取得する方法はありますか?
何かしてから、方向に戻ってください。私の娘は歩こうと歩くことを学びました。 – Bathsheba
この問題を分析する方法についてアドバイスを求めるなら、これは[programmer.se]のほうが良いと思います。 @Bathsheba、最高のアドバイスが、私はあなたが自転車に乗ることを学ぶときに彼女を助けることを願っています;) – AxelH
それは論理的な配列とwhileループを作成するのだろうか? – jermac