Click here to Skip to main content
15,610,660 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

public static void main(String[] args) {
int i = 4;
double d = 4.0;
String s = "HackerRank ";

Scanner scan = new Scanner(;
int i1;
double d1;
String s1;

i1 = scan.nextInt();
d1 = scan.nextDouble();
s1 = scan.nextLine();
s1 = scan.nextLine();


What I have tried:

public static void Main(string[] args)
int i = 4;
double d = 4.0;
string s = "HackerRank ";

Scanner scan = new Scanner(;
int i1;
double d1;
string s1;

i1 = scan.Next();
d1 = scan.NextDouble();
s1 = scan.nextLine();
s1 = scan.nextLine();

Console.WriteLine(i + i1);
Console.WriteLine(d + d1);
Console.WriteLine(s + s1);
Updated 14-May-21 6:06am
Patrice T 14-May-21 10:49am    
And you have a question ?
Dave Kreskowiak 14-May-21 11:02am    
First, you tagged the question as C# but the code you posted is Java.

Second, you never asked a question or stated what the problem is, so it's pretty much impossible to tell you anything useful.

Lastly, HackerRank is no way to learn how to write code.
SeanChupas 14-May-21 12:32pm    
Help with what? I tried reading your mind but all I got was something about a pineapple and a squirrel.

1 solution

If I understand correctly you want to convert Java code to C#.
C# does not have the Scanner() method, you will have to use another way to accomplish this.
Here is an example: C# User Input[^]
And here an example of a scanner class in C#: Java has namespace Scanner class is here something similar in C# - Stack Overflow[^]
Share this answer
BillWoodruff 16-May-21 0:43am    
what is the point of your answering posts that are almost certain to be deleted ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900