我对编程和测试一些我知道的东西非常陌生,我认为我会尝试制作一个程序。但无论输入如何,它都会以 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 );
}
}