0
A person enters his savings that he is kept for one whole year . If his saving is more than 300000 then 2.5% should ne detected otherwise no deduction ahould be made . What will be the coding for that question ?
c#
3 Antworten
+ 3
.
Console.Write( "Enter savings: " );
double savings = Convert.ToDouble( Console.ReadLine() );
double deduction = 0;
if ( savings > 300000 ) {
deduction = savings * 0.025;
savings -= deduction;
Console.WriteLine( "Savings over 300,000 - 2.5% ({0}) deducted.\nNew savings: {1}",
deduction.ToString( "F" ), savings.ToString( "F" ) );
} else {
Console.WriteLine( "Savings less than 300,000 - no deductions" );
}
+ 1
thankx u both 😀
- 1
you can try this:
double savings;
double result;
Console.Write("Enter your savings: ");
savings = Console.ReadLine();
if(savings > 300000.0)
{
result = savings*0,025;
Console.WriteLine("Deducted amout is "+result);
}
else
{
Console.WriteLine("No deduction!");
}