Get the users income systemoutprintWhat is your annual inco
// 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 age + \" and your income is $\" income)
Solution
it can be reading from file or from a particular string income=scanner.nextDouble(); this will scan a double value
which is income. keyword.nextLine() this will skip the next line (this scanner past the current line and returns the input that was skipped. This method returns the rest of the current line) , in next name=keyword.nextLine // here it erturn the name so we store it like
suppost we have input file data like = income
useless data
Name
in this input file for skip 2nd Line we can use nextLine().