0
How to write code for multiple input values to be taken using C #
Multiple values C#
12 Answers
+ 3
Use a loop and get the input inside of the loop.
+ 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() );
+ 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.
0
I'm writing like this
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);
}
}
}
0
To get interest for some amount
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);
}
}
}
0
Still error coming
0
Sampath Suthari What is the error?
It's working fine...
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();
}
}
}
0
Please execute once at your end It is not taking inputs for 3 components
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..