0

How to write code for multiple input values to be taken using C #

Multiple values C#

14th Jul 2022, 1:53 PM
Sampath Suthari
Sampath Suthari - avatar
12 Answers
+ 3
Use a loop and get the input inside of the loop.
14th Jul 2022, 1:57 PM
Lisa
Lisa - avatar
+ 1
Extra ')' at end after Readline() ; error ReadLine() actually accept input in string form so convert into double type by double P = double.Parse( Console.ReadLine() );
14th Jul 2022, 2:15 PM
Jayakrishna 🇮🇳
+ 1
You need to enter all 3 input at once, separated by a line break. Like this: 3 2 1 And please: Put your code in a SCRIPT on sololearn playground – it is much more readable and we can test it. Go to Code section, click +, select the programming language, insert your code, save. Come back to this thread, click +, Insert Code, sort for My Code Bits, select your code.
14th Jul 2022, 3:06 PM
Lisa
Lisa - avatar
0
I'm writing like this
14th Jul 2022, 1:59 PM
Sampath Suthari
Sampath Suthari - avatar
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { double P = Console.ReadLine()); double T=Console.ReadLine()); double R=Console.ReadLine()); Console.WriteLine(P*T*R/100); } } }
14th Jul 2022, 2:07 PM
Sampath Suthari
Sampath Suthari - avatar
0
To get interest for some amount
14th Jul 2022, 2:07 PM
Sampath Suthari
Sampath Suthari - avatar
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { double P = double.Parse(Console.ReadLine ()); double T=double.Parse(Console.ReadLine()); double R=double.Parse(Console.ReadLine()); Console.WriteLine(P*T*R/100); } } }
14th Jul 2022, 2:41 PM
Sampath Suthari
Sampath Suthari - avatar
0
Still error coming
14th Jul 2022, 2:41 PM
Sampath Suthari
Sampath Suthari - avatar
0
Sampath Suthari What is the error? It's working fine...
14th Jul 2022, 2:45 PM
Jayakrishna 🇮🇳
0
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int Years; double Prn,In,Rate,Totalamount; Console.Write("Enter The Loan Amount : "); Prn=Convert.Todouble(Console.ReadLine()); Console.Write("Enter The Interest rate Amount : "); Rate=Convert.Todouble(Console.ReadLine()); Console.Write("Enter The Loan Tenure : "); Years=Convert.Todouble(Console.ReadLine()); In=Prn * Rate * Years/100; Totalamount =In + Prn; Console.WriteLine("Totalamount : {0}", Totalamount); Console.ReadLine(); } } }
14th Jul 2022, 3:02 PM
Sampath Suthari
Sampath Suthari - avatar
0
Please execute once at your end It is not taking inputs for 3 components
14th Jul 2022, 3:02 PM
Sampath Suthari
Sampath Suthari - avatar
0
Year => you are declared as int type but taking input as double ; won't work. Also ToDouble() you are using small d. Use Capital D. And yes... Give all required inputs, line by line at once in pop-up window in SL. It ask inputs only once before starts running code. It's not interactive. Sampath Suthari further anything, share code link by saving it. it makes easy to degug.. hope it helps..
14th Jul 2022, 3:29 PM
Jayakrishna 🇮🇳