01 Day : Data Types

zkpk
Code-30-Days
Published in
1 min readJun 27, 2016

Today’s objective to learn Data Types …Primitive & Reference.

> Read 3 variables via Std In;

> Conduct a simple operation on them;

> Print the results via Std Out;

Code :

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 Scanner(System.in); /* Declare second integer, double, and String variables. */
int myInt = 0;
double myDouble = 0.0;
String myString = “”;
/* Read and save an integer, double, and String to your variables.*/
myInt = scan.nextInt();
myDouble = scan.nextDouble();
scan.nextLine();
myString = scan.nextLine();

/* Print the sum of both integer variables on a new line. */
System.out.println(i + myInt);
/* Print the sum of the double variables on a new line. */
System.out.println(d + myDouble);
/* Concatenate and print the String variables on a new line;
the ‘s’ variable above should be printed first. */
System.out.print(s + myString);
scan.close();
}
}

Input :

12
4.0
is the best place to learn and practice coding!

Output :

16
8.0
HackerRank is the best place to learn and practice coding!

Thank you HackerRank

Follow me PK Rasam

--

--