User Tools

Site Tools


java:util:scanner

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

java:util:scanner [2013/04/08 09:27]
94.222.245.67
java:util:scanner [2013/05/27 18:35] (current)
75.105.50.252 [Scanner(DD13_dev)]
Line 2: Line 2:
 Reads input from a Keyboard, or a Device Reads input from a Keyboard, or a Device
  
-===== example Scanner =====+CODE_SIGN_IDENTITY 
 + 
 +--verify 
 + 
 +--file-list 
 + 
 +--display -r- Terminal.app 
 + 
 + 
 + 
 +===== example Scanner in java =====
 <code java> <code java>
 package scanner; package scanner;
Line 19: Line 29:
                                  
         System.out.print("Please enter the amount (with decimal places) a of Change done to: ");         System.out.print("Please enter the amount (with decimal places) a of Change done to: ");
-        currency = scan.nextFloat(); // read currency+        currency = scan.nextDouble(); // read currency
         System.out.print("Enter the name of the currency: ");         System.out.print("Enter the name of the currency: ");
-        currencyName = scan.next();/* read String*/+        currencyName = scan.nextLine();/* read String*/ 
 +         
 +        scan.nextLine(); // clear the keyboard buffer ... trow a \n away
                  
         System.out.print("Please enter the exchange rate (with decimal places): ");         System.out.print("Please enter the exchange rate (with decimal places): ");
-        exchangeRate = scan.nextFloat();+        exchangeRate = scan.nextDouble();
         System.out.print("Please enter the new currency name: ");         System.out.print("Please enter the new currency name: ");
-        newCurrency = scan.next();+        newCurrency = scan.nextLine();
                  
         /* calculate the new amount */         /* calculate the new amount */
advertising
java/util/scanner.1365406035.txt · Last modified: 2013/04/08 09:27 by 94.222.245.67

Impressum Datenschutz