This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.JOptionPane; | |
/** | |
This program calculates the number of soccer teams | |
that a youth league may create from the number of | |
available players. Input validation is demonstrated | |
with while loops. | |
*/ | |
public class SoccerTeams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This program demonstrates the for loop. | |
*/ | |
public class Squares | |
{ | |
public static void main(String [] args) | |
{ | |
int number; // Loop control variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Needed for the Scanner class | |
/** | |
This program demonstrates a user controlled for loop. | |
*/ | |
public class UserSquares | |
{ | |
public static void main(String[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.DecimalFormat; | |
import javax.swing.JOptionPane; | |
/** | |
This program calculates a running total. | |
*/ | |
public class TotalSales | |
{ | |
public static void main(String[] args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Needed for the Scanner class | |
/** | |
This program calculates the total number of points a | |
soccer team has earned over a series of games. The user | |
enters a series of point values, then -1 when finished. | |
*/ | |
public class SoccerPoints | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This program uses nested loops to simulate a clock. | |
*/ | |
public class Clock | |
{ | |
public static void main(String[] args) | |
{ | |
//Always show two digits. | |
DecimalFormat formatter = new DecimalFormat("00"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Needed for Scanner class | |
import java.io.*; // Needed for File I/O classes | |
/** | |
This program writes data to a file. | |
*/ | |
public class FileWriteDemo | |
{ | |
public static void main(String[] args) throws IOException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Needed for Scanner class | |
import java.io.*; // Needed for File class | |
/** | |
This program reads the first line from a file. | |
*/ | |
public class ReadFirstLine | |
{ | |
public static void main(String[] args) throws IOException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // Needed for the Scanner class | |
import java.io.*; // Needed for the File class | |
/** | |
This program reads data from a file. | |
*/ | |
public class FileReadDemo | |
{ | |
public static void main(String[] args) throws IOException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.Random; | |
/** | |
* This program simulates the rolling of dice. | |
*/ | |
public class RollDice | |
{ | |
public static void main(String[] args) | |
{ |
OlderNewer