import java.io.File; import java.text.DecimalFormat; import java.util.Scanner; public class Exam1Review { public static void main(String[] args) throws Exception { File f = new File("Exam1Review.txt"); // File, Scanner, DecimalFormat, Turtle, World Scanner keyboard = new Scanner(f); while(keyboard.hasNextInt()) { int value = keyboard.nextInt(); System.out.println(value + " % " + 17 + " = " + value % 17); } int x = 95; int y = 3; int r = x % y; System.out.println(r); System.out.println((double)r); System.out.println((char)x); System.out.println((int)'_'); System.out.println((double)'_'); System.out.println((int)3.9); System.out.println((int)-3.9); do { x = x + 1; System.out.println(x); } while (x < 10); DecimalFormat fmt = new DecimalFormat("0.00##"); double n = Math.random(); String number = fmt.format(n); System.out.println(n +" or "+number); System.out.println(number.substring(2,4)); String str = "aserfhyeyhhgt5t6u"; System.out.println(str.indexOf("ysdrfgt")); System.out.println(str.replace("hhh","$$$")); System.out.println(str); // make a number: 0.026 while(Math.random() > 0.05) { // over and over again // i = 4 for(int i = 0; i < 10; ++i) { // ten times System.out.print(i); // print a digit } System.out.println(); // with a new line after each 10 } // 0123456789 // 0123456789 } }