We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 1: Data Types
Day 1: Data Types
+ 0 comments import java.io.; import java.util.;
public class Solution {
public static void main(String[] args) { int i=4; double d=4.0; String s="HackerRank"; Scanner sc = new Scanner(System.in); int i2=sc.nextInt(); double d2=sc.nextDouble(); sc.nextLine(); String s2=sc.nextLine(); System.out.println(i+i2); System.out.println(d+d2); System.out.println(s+" "+s2); sc.close(); }
}
+ 0 comments Here is my solution in Java:
public class Solution {
public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ // declaire first vars int i = 4; double d = 4.0; String s = "HackerRank "; Scanner scan = new Scanner(System.in); //declaire second vars int a = 12; double b = 4.0; String c = "is the best place to learn and practice coding!"; // read and save vars a = scan.nextInt(); b = scan.nextDouble(); scan.nextLine(); c = scan.nextLine(); // print sum System.out.println(i+a); System.out.println(d+b); s = s+c; System.out.print(s); scan.close(); }
}
+ 1 comment Java : int num; double point; String words;
num = scan.nextInt(); point = scan.nextDouble(); scan.nextLine(); words = scan.nextLine(); s = s+words; System.out.println(num+i); System.out.println(point+d); System.out.print(s);
+ 1 comment why can't i use cin and getline() together in c++?
+ 0 comments i = 4 d = 4.0 s = 'HackerRank '
Declare second integer, double, and String variables.
i = 4 d = 4.0 s = 'HackerRank '
Read and save an integer, double, and String to your variables.
i2 = input() d2 = input() s2 = input()
Print the sum of both integer variables on a new line.
print(i + int(i2))
Print the sum of the double variables on a new line.
print(d + float(d2))
Concatenate and print the String variables on a new line
The 's' variable above should be printed first.
print (s + str(s2))
Load more conversations
Sort 3786 Discussions, By:
Please Login in order to post a comment