
Input from Keyboard 4.7
Example 4.4: PrintfJava.java: To Send the Formatted Output Using System.out.
Printf
1.
package com.oops.chap4;
2. import java.util.*;
3. import java.io.*;
4. import javax.swing.JOptionPane;
5. public class PrintfJava {
6. public static void main(String[] args){
7. String name;// variables or reading input date
8. int idNo;
9. double credits,debits,netPay;
10. System.out.println(“Enter Emp name, idNo,credits,debits
separated by spaces”);
11. Scanner scn = new Scanner(System.in);
12. name=scn.next();
13. idNo=scn.nextInt();
14. credits =scn.nextDouble();
15. debits=scn.nextDouble();
16. netPay=credits-debits;
17. ...