我開始學習編程,我在java中做了一個簡單的代碼,添加Java方法編寫
是一個比賽,每個參與者做出叮咬一個蘋果,讓參與者認爲叮咬更重勝!
但是!!我需要在所有的代碼添加與Java方法,功能...你知道
請運行該代碼,您瞭解更多
任何幫助嗎?真的感謝!
import java.io.*;
class reality_show_methods{
public static void main(String[] args)throws java.io.IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintStream out = System.out;
// VARIABLES
int counterParticipants = 1, numPart, numBoc;
double weightBoc, weightBocTotalMayor = 0;
String namePart, nameParticipantWinner = "";
// SETUP
out.print("Number of Participants ......................... ");
numPart = Integer.parseInt(in.readLine());
out.print("Number of Participants Bites: ....... ");
numBoc = Integer.parseInt(in.readLine());
// START
while (counterParticipants <= numPart) {
out.print("\nParticipant Name #" + counterParticipants + " ...................... ");
namePart = in.readLine();
int countBoc = 1;
double weightBocTotal = 0;
while (countBoc <= numBoc) {
out.print("Bite weight #" + countBoc + " of the Participant " + namePart + ": ");
weightBoc = Double.parseDouble(in.readLine());
weightBocTotal = weightBocTotal + weightBoc;
countBoc++;
}
if (weightBocTotalMayor < weightBocTotal) {
weightBocTotalMayor = weightBocTotal;
nameParticipantWinner = namePart;
}
counterParticipants++;
}
// SHOW WINNER
out.println("\nParticipant Winner: ................... " + nameParticipantWinner + " with Total Weight: " + weightBocTotalMayor);
}
}
你的問題是? – bezmax
Max是正確的 - 您需要向我們提供更多關於您想知道的信息。你認爲什麼是代碼錯誤,你認爲我們可以提供什麼幫助? – Bringer128
我想首先猜測:你的意思是你必須將代碼分解成方法,而不是一切都在主要? – LeleDumbo