| Operator and Expression | ||||||||||||||||
| Arithmetic assignment operations | ||||||||||||||||
|
||||||||||||||||
| Example: | ||||||||||||||||
| This program reads a percentage value from the user (such as 5.5) and converts to the correct decimal equivalent (such as 0.055) by using the division assignment operator. | ||||||||||||||||
| import java.util.*; import java.io.*; public class AppStr { public static void main(String[] args) { // Variable for holding a percentage entered by the user // Prompt for and read the percentage System.out.print("Enter a percentage in n.nn format: "); double percent; Scanner Keyboard = new Scanner(System.in); percent = Keyboard.nextDouble(); //percent = Keyboard.readDouble(); // Convert it to its decimal equivalent and display the result percent /= 100; System.out.println("The decimal equivalent is " + percent); } } |
||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||