第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何計(jì)算和顯示 NFL 傳球手評(píng)分?

如何計(jì)算和顯示 NFL 傳球手評(píng)分?

HUH函數(shù) 2023-08-16 18:07:44
我正在嘗試做這個(gè)家庭作業(yè)問(wèn)題,但我在設(shè)置它和理解如何開始和完成這些結(jié)果時(shí)遇到困難。到目前為止,我已經(jīng)聲明了公式的變量,創(chuàng)建了掃描儀并嘗試編寫公式。這是我到目前為止所擁有的:?//declaring variables? float a_CompletionPercentage, b_YardsPerAttempt, c_TouchdownsPerAttempt, d_InterceptionsPerAttempt;? float PasserRating;? double Completion, Attempts, Touchdowns, Yards, Interceptions;? Scanner in = new Scanner(System.in); //create Scanner Object? //PlayerName input? System.out.print("Enter the full name of the quarterback: "); //prompt asks for player name? String PlayerName = in.nextLine(); //set string PlayerName as user's input? //attempts input? System.out.print("Enter the number of attempts: "); //prompt asks for # of attempts? Attempts = in.nextDouble(); //set variable Attempts as user's input for # of attempts? //completion input? System.out.print("Enter the number of completions: ");?? Completion = in.nextDouble();?? //yards input? System.out.print("Enter the number of yards: ");?? Yards = in.nextDouble();? //touchdowns input? System.out.print("Enter the number of touchdowns: ");?? Touchdowns = in.nextDouble();?? //interceptions input? System.out.print("Enter the number of interceptions: ");?? Interceptions = in.nextDouble();?我不確定我的變量是否已正確聲明并且我的公式不起作用。這些是我應(yīng)該得到的一些示例輸出:輸出示例 1:輸入四分衛(wèi)的全名:Jameis Winston輸入嘗試次數(shù):35輸入完成次數(shù):22輸入碼數(shù):345輸入達(dá)陣次數(shù):4輸入攔截次數(shù):1Jameis Winston 的傳球者評(píng)分為 121.72619047619047但我得到的是 664.58325 而不是 121.72619047619047。
查看完整描述

3 回答

?
胡說(shuō)叔叔

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超8個(gè)贊

你的公式不正確。


這里:


b_YardsPerAttempt = (((float)(Yards/Attempts)- 3f) * 5f);

當(dāng)您應(yīng)該乘以 0.25 時(shí),您卻將 (碼數(shù)/嘗試次數(shù) - 3) 的結(jié)果乘以 5。這就是你的計(jì)算出現(xiàn)錯(cuò)誤的地方。


請(qǐng)記住,您不應(yīng)以大寫開頭字母命名變量。此外,在計(jì)劃使用新變量之前聲明它們也是一個(gè)很好的做法。這是一個(gè)片段,您可以看看如何寫得更好一些。


Scanner in = new Scanner(System.in);


System.out.print("Enter the full name of the quarterback: ");

String playerName = in.nextLine();


System.out.print("Enter the number of attempts: ");

Double attempts = in.nextDouble();


System.out.print("Enter the number of completions: ");

Double completion = in.nextDouble();



System.out.print("Enter the number of yards: ");

Double yards = in.nextDouble();


System.out.print("Enter the number of touchdowns: ");

Double touchdowns = in.nextDouble();


System.out.print("Enter the number of interceptions: ");

Double interceptions = in.nextDouble();


Double completionPercentage = ((completion / attempts - 0.3) * 5);

Double yardsPerAttempt = (((yards / attempts) - 3) * 0.25);

Double touchdownsPerAttempt = ((touchdowns / attempts) * 20);

Double interceptionsPerAttempt = (2.375 - ((interceptions / attempts) * 25));


Double passerRating = (((completionPercentage + yardsPerAttempt + touchdownsPerAttempt + interceptionsPerAttempt) / 6) * 100);


System.out.println("The passer rating for " + playerName + " is " + passerRating);


希望這可以幫助!


查看完整回答
反對(duì) 回復(fù) 2023-08-16
?
汪汪一只貓

TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊

我在變量及其格式的聲明方面遇到了問(wèn)題。


我已經(jīng)修復(fù)了代碼,現(xiàn)在如果有人感興趣的話它可以根據(jù)需要工作,這是我的最終工作代碼:


?//declaring variables

? double a_CompletionPercentage, b_YardsPerAttempt, c_TouchdownsPerAttempt, d_InterceptionsPerAttempt;

? double PasserRating;

? int Completion, Attempts, Touchdowns, Yards, Interceptions;



? Scanner in = new Scanner(System.in); //create Scanner Object



? //PlayerName input

? System.out.print("Enter the full name of the quarterback: "); //prompt asks for player name

? String PlayerName = in.nextLine(); //set string PlayerName as user's input


? //attempts input

? System.out.print("Enter the number of attempts: "); //prompt asks for # of attempts

? Attempts = in.nextInt(); //set variable Attempts as user's input for # of attempts


? //completion input

? System.out.print("Enter the number of completions: ");?

? Completion = in.nextInt();?


? //yards input

? System.out.print("Enter the number of yards: ");?

? Yards = in.nextInt();


? //touchdowns input

? System.out.print("Enter the number of touchdowns: ");?

? Touchdowns = in.nextInt();?


? //interceptions input

? System.out.print("Enter the number of interceptions: ");?

? Interceptions = in.nextInt();?


? //calculations?

? if (Attempts == 0) {

? ? ? ? System.out.println("The passer rating for " + PlayerName + " is " + 0);


? } else {


? ? ?a_CompletionPercentage = ((double)Completion /Attempts - 0.3) * 5.0; //formula for completion percentage

? ? ?b_YardsPerAttempt =? ? ? ((double)Yards? ? ? /Attempts - 3.0) * 0.25; //formula for yards per attempt

? ? ?c_TouchdownsPerAttempt = ((double)Touchdowns /Attempts)? ? ? ?* 20.0; //formula for touchdowns per attempt

? ? ?d_InterceptionsPerAttempt = 2.375f - ((double)Interceptions /Attempts * 25.0); //formula for interceptions per attempt


? ? ?//formula for passing rate

? ? ?PasserRating = (((a_CompletionPercentage + b_YardsPerAttempt + c_TouchdownsPerAttempt + d_InterceptionsPerAttempt)/6.0) * 100.0);?



? ? ?//Displays result

? ? ?if (PasserRating < 0){

? ? ? ? System.out.println("The passer rating for " + PlayerName + " is " + 0);

? ? ?} else{

? ? ? ? System.out.println("The passer rating for " + PlayerName + " is " + PasserRating);

? ? ?}

? }



查看完整回答
反對(duì) 回復(fù) 2023-08-16
?
炎炎設(shè)計(jì)

TA貢獻(xiàn)1808條經(jīng)驗(yàn) 獲得超4個(gè)贊

您沒有遵循變量名稱等的常用 Java 編碼約定。這會(huì)使您的代碼可讀性較差。從學(xué)習(xí)它們開始。

像大多數(shù)新手程序員一樣,您將太多精力集中在輸入上,而沒有足夠地編寫正確的函數(shù)。

現(xiàn)在學(xué)習(xí)JUnit還不算太早,?我建議編寫五個(gè)函數(shù):

public interface PasserRatingCalculator {

? ? default double calculateCompletionPercentage(int numAttempts, int numCompletions) { return ((double)numCompletions)/numAttempts; }

? ? double calculateYardsPerAttempt(int numAttempts, int numYards) { return ((double)numYards/numAttempts; }

? ? double calculateTouuchdownsPerAttempt(int numAttempts, int numTouchdowns) { return ((double)numTouchdowns)/numAttempts; }

? ? double calculateInterceptionsPerAttempt(int numAttempts, int numInterceptions) { return ((double)numInterceptions)/numAttempts; }

? ? double calculatePasserRating(numAttempts, int numCompletions, int numYards, int numTouchdowns, int numCompletions);? ? ? ??

}


查看完整回答
反對(duì) 回復(fù) 2023-08-16
  • 3 回答
  • 0 關(guān)注
  • 264 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)