Skip to content

Instantly share code, notes, and snippets.

View khatchad's full-sized avatar

Raffi Khatchadourian khatchad

View GitHub Profile
@khatchad
khatchad / SoccerTeams.java
Created March 23, 2015 19:37
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.
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
@khatchad
khatchad / Squares.java
Created March 23, 2015 19:38
This program demonstrates the for loop.
/**
This program demonstrates the for loop.
*/
public class Squares
{
public static void main(String [] args)
{
int number; // Loop control variable
@khatchad
khatchad / UserSquares.java
Created March 23, 2015 19:39
This program demonstrates a user controlled for loop.
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)
{
@khatchad
khatchad / TotalSales.java
Created March 23, 2015 19:41
This program calculates a running total.
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
/**
This program calculates a running total.
*/
public class TotalSales
{
public static void main(String[] args)
@khatchad
khatchad / SoccerPoints.java
Created March 23, 2015 19:42
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.
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
{
@khatchad
khatchad / Clock.java
Last active May 12, 2022 22:29
This program uses nested loops to simulate a clock.
/**
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");
@khatchad
khatchad / FileWriteDemo.java
Created March 30, 2015 19:38
This program writes data to a file.
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
@khatchad
khatchad / ReadFirstLine.java
Created March 30, 2015 19:40
This program reads the first line from a file.
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
@khatchad
khatchad / FileReadDemo.java
Created March 30, 2015 19:41
This program reads data from a file.
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
@khatchad
khatchad / RollDice.java
Last active August 29, 2015 14:18
This program simulates the rolling of dice.
import java.util.Scanner;
import java.util.Random;
/**
* This program simulates the rolling of dice.
*/
public class RollDice
{
public static void main(String[] args)
{