Addition of Numbers Using io.DataInputStream
import java.io.DataInputStream;
class Addition{
public static void main(String[]args) throws Exception{
DataInputStream ob = new DataInputStream(System.in);
/* we created the object of DIS class
*/
System.out.print("Enter First Number");
String s = ob.readLine();
int a = Integer.parseInt(s);
/** we cnvert the string value into integer and save into a variable **/
System.out.print("Enter second Number");
String d = ob.readLine();
int b = Integer.parseInt(d);
int sum = a+b;
System.out.println("Addition: " + sum);
}
}
/* line 6 and 7 can be written as
int b = Integer.parseInt(ob.readLine());
Assignments
Perform All Airthematic operators
Marksheet:
Subject1 Marks
Subject2 Marks
Subject2 Marks
Subject2 Marks
Subject2 Marks as inputs
gives output as
Total Marks
Obtain Marks
Percentage
*/
No comments:
Post a Comment