|
|
Line 23: |
Line 23: |
| ==Documentation== | | ==Documentation== |
| | | |
− | ====Goal 1 ( )====
| |
− | <pre>
| |
− | public class dice {
| |
− | public static void main(String[] args) {
| |
− | int roll1;
| |
− | int roll2;
| |
− | roll1 = (int)(Math.random()*6) + 1;
| |
− | roll2 = (int)(Math.random()*6) + 1;
| |
− |
| |
− | System.out.println("The first die comes up " + roll1);
| |
− | System.out.println("The second die comes up " + roll2);
| |
− | System.out.println("Your total roll is " + (roll1+roll2));
| |
| | | |
− | }
| |
− |
| |
− | }
| |
− | </pre>
| |
− | <pre>
| |
− | import java.io.*;
| |
− |
| |
− | public class name {
| |
− | private static BufferedReader stdin =
| |
− | new BufferedReader( new InputStreamReader( System.in ) );
| |
− |
| |
− | public static void main(String[] args) throws IOException {
| |
− |
| |
− | String person;
| |
− |
| |
− | System.out.println("Please enter your name: ");
| |
− | person = stdin.readLine();
| |
− |
| |
− | System.out.println("Hello, " + person.toUpperCase() + ", nice to meet you!");
| |
− |
| |
− | }
| |
− |
| |
− | }
| |
− | </pre>
| |
− | <pre>
| |
− | import java.io.*;
| |
− |
| |
− | public class change {
| |
− | private static BufferedReader stdin =
| |
− | new BufferedReader( new InputStreamReader( System.in ) );
| |
− |
| |
− | public static void main(String[] args) throws IOException {
| |
− |
| |
− | System.out.println("How many quarters do you have?: ");
| |
− | String quarters = stdin.readLine();
| |
− | int quartersint = Integer.parseInt(quarters);
| |
− |
| |
− | System.out.println("How many dimes do you have?: ");
| |
− | String dimes = stdin.readLine();
| |
− | int dimesint = Integer.parseInt(dimes);
| |
− |
| |
− | System.out.println("How many nickels do you have?: ");
| |
− | String nickels = stdin.readLine();
| |
− | int nickelsint = Integer.parseInt(nickels);
| |
− |
| |
− | System.out.println("How many pennies do you have?: ");
| |
− | String pennies = stdin.readLine();
| |
− | int penniesint = Integer.parseInt(pennies);
| |
− |
| |
− | double total = quartersint*.25 + dimesint*.1 + nickelsint*.05 + penniesint*.01;
| |
− |
| |
− | System.out.println("You have $" + total + "!");
| |
− |
| |
− | }
| |
− |
| |
− | }
| |
− | </pre>
| |
− | <pre>
| |
− | import java.io.*;
| |
− |
| |
− | public class eggs {
| |
− | private static BufferedReader stdin =
| |
− | new BufferedReader( new InputStreamReader( System.in ) );
| |
− |
| |
− | public static void main(String[] args) throws IOException {
| |
− |
| |
− | System.out.println("How many eggs do you have?: ");
| |
− | String eggstr = stdin.readLine();
| |
− | int eggint = Integer.parseInt(eggstr);
| |
− |
| |
− | int gross = eggint/144;
| |
− | int dozen = eggint/12;
| |
− | int leftover = eggint%12;
| |
− |
| |
− | System.out.println("Your number of eggs is " + gross + " gross, " +
| |
− | dozen + " dozen, and " + leftover + " left over.");
| |
− |
| |
− | }
| |
− |
| |
− | }
| |
− | </pre>
| |
− | <!--
| |
− | ====Goal 2 ( )====
| |
− |
| |
− | ====Goal 3 ( )====
| |
− |
| |
− | ====Goal 4 ( )====
| |
− |
| |
− | ====Goal 5 ( )====
| |
− |
| |
− | ====Goal 6 ( )====
| |
− |
| |
− | ====Goal 7 ( )====
| |
− |
| |
− | ====Goal 8 ( )====
| |
− |
| |
− | ====Goal 9 ( )====
| |
− |
| |
− | ====Goal 10 ( )====
| |
− | -->
| |
| | | |
| ==References== | | ==References== |
| <small><references/></small> | | <small><references/></small> |