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#

11th Sep 2016, 7:13 PM
Eshaal Khan
Eshaal Khan - avatar
3 Respostas
+ 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" ); }
12th Sep 2016, 1:59 AM
Liam
Liam - avatar
+ 1
thankx u both 😀
12th Sep 2016, 6:45 AM
Eshaal Khan
Eshaal Khan - avatar
- 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!"); }
11th Sep 2016, 7:48 PM
Ilyosjon Kamoldinov
Ilyosjon Kamoldinov - avatar