Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does my program keep responding with a zero?
    text
    copied!<p>I am very new to programming and to test some of the things I know I thought I would try and make a program. But it keeps responding with 0 regardless of the inputs. I'm sorry if its messy, but within my framework of understanding can you show a fix?</p> <p>Thanks for any help you provide.</p> <h2>Code</h2> <pre><code>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 &lt;= 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 &gt;= 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 &lt;= -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 ); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload