私はプログラミングに非常に慣れていないので、プログラムを作成しようと思ったことがわかっていることのいくつかをテストします。ただし、入力に関係なく、0で応答し続けます。散らかっていたら申し訳ありませんが、私の理解の枠内で修正を示すことができますか?
あなたが提供するどんな助けにも感謝します。
コード
class Program
{
static void Main( string[] args ) {
// Probability of Hitting
Console.WriteLine( "Welcome to the Ranged Death Calculator, please enter the Ballistic Skill (BS) " + Environment.NewLine + "of the model firing." );
float BallisticSkillf = Convert.ToSingle( Console.ReadLine() );
float WSProbabilityf;
if( BallisticSkillf <= 5 ) {
WSProbabilityf = Convert.ToSingle( ( BallisticSkillf / 6 ) );
}
else {
WSProbabilityf = Convert.ToSingle( ( ( 5 / 6 ) ) + ( 1 / 6 * ( ( BallisticSkillf - 6 ) / 6 ) ) );
}
// Probability of Wounding
Console.WriteLine( "Please enter the toughness of your target" );
float TargetToughnessf = Convert.ToSingle( Console.ReadLine() );
Console.WriteLine( "Please enter the strength of the Weapon firing" );
float WeaponStrengthf = Convert.ToSingle( Console.ReadLine() );
float WoundProbabilityf = 0;
if( WeaponStrengthf - TargetToughnessf >= 2 )
WoundProbabilityf = ( (float)( 5 / 6 ) );
else if( WeaponStrengthf - TargetToughnessf == 1 )
WoundProbabilityf = ( (float)( 4 / 6 ) );
else if( WeaponStrengthf - TargetToughnessf == 0 )
WoundProbabilityf = ( (float)( 3 / 6 ) );
else if( WeaponStrengthf - TargetToughnessf == -1 )
WoundProbabilityf = ( (float)( 2 / 6 ) );
else if( WeaponStrengthf - TargetToughnessf <= -2 )
WoundProbabilityf = ( (float)( 1 / 6 ) );
//Probability of failing saving throw
Console.WriteLine( "Please enter the relevant armour save of the target, (So, 2, would be for 2+, , 3+ etc.) (Also, take into consideration the AP Value of the weapon fired)" );
float nTargetRelevantSave = Convert.ToSingle( Console.ReadLine() );
float TRProbabilityf = ( (float)( ( nTargetRelevantSave - 1 ) / 6 ) );
// Number of shots fired
Console.WriteLine( "Finally, please enter the number of shots fired with the weapon" );
float nShotsFromWeapon = Convert.ToSingle( Console.ReadLine() );
// All previous values to determine likely number of wounds inflicted
float nWoundsInflictedf = ( (float)WSProbabilityf * (float)WoundProbabilityf * (float)TRProbabilityf * (float)nShotsFromWeapon );
Console.WriteLine( "The number of wounds you are likely to inflict is " + (float)nWoundsInflictedf );
}
}