Task
The variables =4,d= 4.0, and ="Javarenian " are declared and initialized . You must declare variables: one of type int, one of type double, and one of type String. Then you must read lines of input from stdin and initialize your variables. Finally, you must use the operator to perform the following operations:
The first line contains an integer, .
The second line contains a double, .
The third line contains a string, .
The variables =4,d= 4.0, and ="Javarenian " are declared and initialized . You must declare variables: one of type int, one of type double, and one of type String. Then you must read lines of input from stdin and initialize your variables. Finally, you must use the operator to perform the following operations:
- Print the sum of plus your int variable on a new line.
- Print the sum of plus your double variable to a scale of one decimal place on a new line.
- Concatenate with the string you read as input and print the result on a new line.
Input Format
The first line contains an integer, .
The second line contains a double, .
The third line contains a string, .
package college;
ReplyDeleteimport java.util.*;
class Demo
{
public static void main(String args[])
{
int i=4;
double d= 4.0;
String s= "Javarenian ";
Scanner scan = new Scanner(System.in);
int a;
double b;
String c;
a=scan.nextInt();
b=scan.nextDouble();
scan.nextLine();
c=scan.nextLine();
System.out.println(a+i);
System.out.println(b+d);
System.out.println(s+c);
}
}