Hackerrank 30 days of code Java Solution Day 1 Data types

Coding Challenge Coding Live

Print the sum of i plus your int variable on a new line.

Hackerrank 30 days of code Java Solution: Day 6: Lets Review

Print the sum of d plus your double variable to a scale of one decimal place on a new line.

Hackerrank 30 days of code Java Solution: Day 12: Inheritance

Hackerrank 30 days of code Java Solution: Day 15: Linked List

Hackerrank 30 days of code Java Solution: Day 10: Binary Numbers

Hackerrank 30 days of code Java Solution: Day 16: Exceptions String to Integer

Hackerrank 30 days of code Java Solution: Day 16: Exceptions String to Integer

How to configure Early Watch Alert Report

I know that we have to use scan.nextLine() to read string input.

Hackerrank 30 days of code Java Solution: Day 17: More Exceptions

Hackerrank 30 days of code Java Solution: Day 2 Operators

Save my name, email, and site URL in my browser for next time I post a comment.

Click to email this to a friend (Opens in new window)

/* Concatenate and print the String variables on a new line;

Hackerrank 30 days of code Java Solution: Day 11: 2D Arrays

Concatenate s with the string you read as input and print the result on a new line.

Hackerrank 30 days of code Java Solution: Day 8: Dictionaries and Maps

Hackerrank Java Advanced Challenges: Prime Checker

Hackerrank 30 days of code Java Solution: Day 7: Arrays

Hackerrank 30 days of code Java Solution: Day 5: Loops

Click to share on LinkedIn (Opens in new window)

/* Read and save an integer, double, and String to your variables.*/

Hackerrank 30 days of code Java Solution: Day 13: Abstract Classes

Hackerrank 30 days of code Java Solution: Day 17: More Exceptions

Click to share on Google+ (Opens in new window)

Hackerrank 30 days of code Java Solution: Day 14: Scope

Hackerrank 30 days of code Java Solution: Day 13: Abstract Classes

Print the sum of both integers on the first line, the sum of both doubles on the second line, and then the two concatenated strings on the third line.

Hackerrank 30 days of code Java Solution: Day 15: Linked List

Note: If you are using a language that doesnt support using ++ for string concatenation (e.g.: CC), you can just print one variable immediately following the other on the same line. The string provided in your editor must be printed first, immediately followed by the string you read as input.

Hackerrank Java Advanced Challenges: Can You Access ?

/* Declare second integer, double, and String variables. */

/* Print the sum of the double variables on a new line. */

Complete the code in the editor below. The variables i, d, and s are already declared and initialized for you. You must declare 3 variables: one of type int, one of type double, and one of type String. Then you must read 3 lines of input from stdin and initialize your 3 variables. Finally, you must use the ++ operator to perform the following operations:

Java Interview Questions you never thought off

the s variable above should be printed first. */

Hackerrank 30 days of code Java Solution: Day 14: Scope

Hackerrank Java Advanced Challenges: Prime Checker

Hackerrank 30 days of code Java Solution: Day 9: Recursion

The first line contains an integer, i.

The second line contains a double, d.

Hackerrank Java Advanced Challenges: Can You Access ?

Click to share on Facebook (Opens in new window)

Hackerrank 30 days of code Java Solution: Day 18: Queues and Stacks

The third line contains a string, s.

Notify me of follow-up comments by email.

HackerRank is the best place to learn and practice coding!

import java.io.*; 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 ); /* Declare second integer, double, and String variables. */ int j=scan.nextInt(); /* Read and save an integer, double, and String to your variables.*/ double k=scan.nextDouble(); scan.nextLine(); String str=scan.nextLine(); /* Print the sum of both integer variables on a new line. */ System.out.println(i+j); /* Print the sum of the double variables on a new line. */ System.out.println(d+k); /* Concatenate and print the String variables on a new line; the s variable above should be printed first. */ System.out.println(s+ +str); scan.close();

is the best place to learn and practice coding!

Your email address will not be published.Required fields are marked*

Hackerrank 30 days of code Java Solution: Day 18: Queues and Stacks

But why you used it twice because it really matters Ive spent more than half hour for this problem and thanks to you for the solution

/* Print the sum of both integer variables on a new line. */

Hi Avinash, This is probably Hackerrank is giving an extra line seperator between the nextDouble and String input. The code would have worked fine without extra nextLine(),if the parameter are given in same line separated by space,Check here nextLine() actually buffers the input till the line separator and shows the result. Hope it helps ?

Click to share on WhatsApp (Opens in new window)

Leave a Reply