Difference between revisions of "Nick Apseloff 3rd Quarter"
From WLCS
(→Documentation) |
|||
| Line 22: | Line 22: | ||
==Documentation== | ==Documentation== | ||
| − | + | ||
====Goal 1 ( )==== | ====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> | ||
| + | <!-- | ||
====Goal 2 ( )==== | ====Goal 2 ( )==== | ||
| Line 43: | Line 112: | ||
====Goal 10 ( )==== | ====Goal 10 ( )==== | ||
--> | --> | ||
| + | |||
==References== | ==References== | ||
<small><references/></small> | <small><references/></small> | ||
Revision as of 10:34, 23 January 2009
Contents
Goals
1. [ ]
2. [ ]
3. [ ]
4. [ ]
5. [ ]
6. [ ]
7. [ ]
8. [ ]
9. [ ]
10. [ ]
Documentation
Goal 1 ( )
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));
}
}
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!");
}
}
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 + "!");
}
}
References