2-31 CorractedinputProblm

posted Jan 19, 2014, 12:49 AM by dldar masud   [ updated Jan 19, 2014, 9:48 AM by Karwan Jacksi ]
   //CorractedinputProblm

    package corractadlnputproblm;

    import java.util.Scanner; // Needed for the Scanner class

    //This program correctly reads numeric and string input.


     public class CorractadlnputProblm {


    public static void main(String[] args) {

        // TODO code application logic here

         String name; // To hold the user's name
         int age; // To hold the user's age
         double income; // T o hold the user's inc

        // Create a Scanner object to read input.
        Scanner keyboard = new Scanner(System.in);

        // Get the user's age.
        System.out.print("What is your age? " );
        age = keyboard.nextInt();

         // Get the user's income
         System.out.print("What is your annual income? " );
         income = keyboard.nextDouble();

          // Consume the remaining newline.
          keyboard.nextLine();

           // Get the user's name.
           System.out.print("What is your name? " );
           name = keyboard.nextLine();

           // Display the information back to the user.
           System.out.println("Hello, " + name +  ". Your age is "+
           age + " and your income i s S" +
           income);
           }
   
      }

ċ
CorractadlnputProblm.java
(1k)
Karwan Jacksi,
Jan 19, 2014, 12:49 AM
Comments