Questions
Complete the following Customer class below. Also, add the equals method that would compare each field....

Complete the following Customer class below. Also, add the equals method that would compare each field.

Please pay attention to the format of the equals method as it needs to have the same format as shown below.

public class Customer {

      private int id; //customer id

      private String name; //customer's name

      private int discount; //discount rate in percent

     

      //construct a new customer

      public Customer(int id, String name, int discount) {

            

      }

      //returns the field values

      public int getId () {

            

             }

     

      public String name () {

            

             }

     

      public int discount () {

            

             }

     

      //returns String for customer. Eg: "Mary, id:1111, discount 10%"

     

      public String toString () {

            

      }

     

      public boolean equals (Object other) {

      if (other instanceof some_class) {

             //do casting

             return logical_statement_for_comparison;

      } else {

             return false;

      }

      }

In: Computer Science

2. Report Heading Design a class called Heading that has data members to hold the company...

2. Report Heading Design a class called Heading that has data members to hold the company name and the report name. A two-parameter default constructor should allow these to be specified at the time a new Heading object is created. If the user creates a Heading object without passing any arguments, “ABC Industries” should be used as a default value for the company name and “Report” should be used as a default for the report name. The class should have member functions to print a heading in either one-line format, as shown here: Pet Pals Payroll Report or in four-line “boxed” format, as shown here: ******************************************************** Pet Pals Payroll Report ******************************************************** Try to figure out a way to center the headings on the screen, based on their lengths. Demonstrate the class by writing a simple program that uses it.

In: Computer Science

In Python Create customer information system as follows: Ask the user to enter name, phonenumber, email....

In Python Create customer information system as follows:

Ask the user to enter name, phonenumber, email. Create a file by his name and save it in the hard disk. Do this repeatedly until all the users are entered. (for example, if the user enters 10 customers’s information, there should be 10 different files created.)

Now build the customer value for a retail company as follows:

Ask the customer to enter his name. If you have his information already stored, then showing him his stored number and email. If not, ask his phone and email and save on his name.

Ask him to enter what he buying (itemname, quantity, unit price.) repeatedly until he enters all the items. Calculate the total including the tax (0.0825). Append the total price to his file.

In: Computer Science

1. On an index card or piece of notebook paper, draw a structure (see #3 below)...

1. On an index card or piece of notebook paper, draw a structure (see #3 below)

2. For the structure you draw, indicate how many total peaks it would have in its regular 13C NMR spectrum, how many DEPT 90 peaks, how many negative peaks in the DEPT 135, and finally how many positive peaks in DEPT 135.

3. Please use the following parameters for your structure:

LAST NAME A-C: a compound with 8 carbons or less that does NOT include a ring

LAST NAME D-H: a compound with between 9 and 12 carbons that includes a ring

LAST NAME L-Sal: a compound with 8 carbons or less that includes a ring

LAST NAME Set-W:    a compound with between 9 and 12 carbons that does NOT include a ring

In: Chemistry

Write program#1 upload .java file. #1 Write a java program that prompts the user for input...

Write program#1 upload .java file.

#1 Write a java program that prompts the user for input using the Scanner class.

  • First to enter their first name.
  • Then prompts the user to enter their last name.
  • Then prompts the user to enter their city.
  • Then prompts the user to enter their state.
  • Then prompts the user to enter their zip code.  
  • Concatenate first name and last name into full_name. Using String Class is optional.
  • Use the String Class to replace zip code "0" with "N", replace "7" with "J".
  • Use the String Class to make all the values upper case.
  • Use the String Class to determine the length of full_name.  
  • Print on first line full_name and length of full_name.
  • Print all on second line mailing address, including zip_string.

<END>

In: Computer Science

David R. and Ella M. Cole (ages 39 and 38, respectively) are husband and wife who...

David R. and Ella M. Cole (ages 39 and 38, respectively) are husband and wife who live at 1820 Elk Avenue, Denver, CO 80202. David is a regional sales manager for Wren Industries, a national wholesaler of plumbing and heating supplies, and Ella is a part-time dental hygienist for a chain of dental clinics.

David is classified by Wren as a statutory employee with compensation for 2016 (based on commissions) of $95,000. He is expected to maintain his own office and pay for all business expenses from this amount. Wren does not require him to render any accounting as to the use of these funds. It does not withhold Federal and state income taxes but does withhold and account for the payroll taxes incurred (e.g., Social Security and Medicare). The Coles are adequately covered by Wren's noncontributory medical plan but have chosen not to participate in its § 401(k) retirement plan.

David's employment-related expenses for 2016 are summarized below.

Airfare $8,800
Lodging 5,000
Meals (during travel status) 4,800
Entertainment 3,600
Ground transportation (e.g., limos, rental cars, and taxis) 800
Business gifts 900
Office supplies (includes postage, overnight delivery, and copying) 1,500

The entertainment involved business meals for purchasing agents, store owners, and building contractors. The business gifts consisted of $50 gift certificates to a national restaurant. These were sent by David during the Christmas holidays to 18 of his major customers.

In addition, David drove his 2014 Ford Expedition 11,000 miles for business and 3,000 for personal use during 2016. He purchased the Expedition on August 15, 2013, and has always used the automatic (standard) mileage method for tax purposes. Parking and tolls relating to business use total $340 in 2016.

When the Coles purchased their present residence in April 2013, they devoted 450 of the 3,000 square feet of living space to an office for David. The property cost $440,000 ($40,000 of which is attributable to the land) and has since appreciated in value. Expenses relating to the residence in 2016 (except for mortgage interest and property taxes; see below) are as follows:

Insurance

$2,600

Repairs and maintenance

900

Utilities 4,700
Painting office area; area rugs and plants (in the office)* 1,800
*Treat as a direct office in home expense.

In terms of depreciation, the Coles use the MACRS percentage tables applicable to 39-year nonresidential real property. As to depreciable property (e.g., office furniture), David tries to avoid capitalization and uses whatever method provides the fastest write-off for tax purposes.

Ella works part-time as a substitute for whichever hygienist is ill or on vacation or when one of the clinics is particularly busy (e.g., prior to the beginning of the school year). Assumed that Ella is an employee (not an independent contractor). Besides her transportation, she must provide and maintain her own uniforms. Her expenses for 2016 appear below.

Uniforms $690
State and city occupational licenses 380
Professional journals and membership dues in the American Dental
      Hygiene Association
340
Correspondence study course (taken online) dealing with teeth
      whitening procedures
420

Ella's salary for the year is $42,000, and her Form W–2 for the year shows income tax withholdings of $4,000 (Federal) and $1,000 (state) and the proper amount of Social Security and Medicare taxes. Because Ella is a part-time employee, she is not included in her employer's medical or retirement plans.

Besides the items already mentioned, the Coles had the following receipts during 2016.

Interest income—
     State of Colorado general purpose bonds $2,500
     IBM bonds 800
     Wells Fargo Bank 1,200 $    4,500
Federal income tax refund for year 2015 510
Life insurance proceeds paid by Eagle Assurance
     Corporation
200,000
Inheritance of savings account from Sarah Cole 50,000
Sales proceeds from two ATVs 9,000

For several years, the Coles' household has included David's divorced mother, Sarah, who has been claimed as their dependent. In late November 2016, Sarah unexpectedly died of coronary arrest in her sleep. Unknown to Ella and David, Sarah had a life insurance policy and a savings account (with David as the designated beneficiary of each). In 2015, the Coles purchased two ATVs for $14,050. After several near mishaps, they decided that the sport was too dangerous. In 2016, they sold the ATVs to their neighbor.

Additional expenditures for 2016 include:

Funeral expenses for Sarah $   4,500
Taxes—
     Real property taxes on personal residence $6,400
     Colorado state income tax due (paid in April
          2016 for tax year 2015)
310 6,710
Mortgage interest on personal residence (Rocky Mountain Bank) 6,600
Paid church pledge 2,400
Contributions to traditional IRAs for Ella and David
     ($5,500 + $5,500)
11,000

In 2016, the Coles made quarterly estimated tax payments of $1,400 (Federal) and $500 (state) for a total of $5,600 (Federal) and $2,000 (state).

Relevant Social Security numbers are:

David Cole 123-45-6788
Ella Cole 123-45-6787
Sarah Cole 123-45-6799

Required:

Using the appropriate forms and schedules, compute the Coles' Federal income tax for 2016. Disregard the alternative minimum tax (AMT) and the various education credits

In: Accounting

Budgeted Income Statement and Supporting Budgets The budget director of Feathered Friends Inc., with the assistance...

Budgeted Income Statement and Supporting Budgets The budget director of Feathered Friends Inc., with the assistance of the controller, treasurer, production manager, and sales manager, has gathered the following data for use in developing the budgeted income statement for December 2016: Estimated sales for December: Bird house 3,200 units at $50 per unit Bird feeder 3,000 units at $70 per unit Estimated inventories at December 1: Direct materials: Wood 200 ft. Plastic 240 lbs. Finished products: Bird house 320 units at $27 per unit Bird feeder 270 units at $40 per unit Desired inventories at December 31: Direct materials: Wood 220 ft. Plastic 200 lbs. Finished products: Bird house 290 units at $27 per unit Bird feeder 250 units at $41 per unit Direct materials used in production: In manufacture of Bird House: Wood 0.80 ft. per unit of product Plastic 0.50 lb. per unit of product In manufacture of Bird Feeder: Wood 1.20 ft. per unit of product Plastic 0.75 lb. per unit of product Anticipated cost of purchases and beginning and ending inventory of direct materials: Wood $7.00 per ft. Plastic $1.00 per lb. Direct labor requirements: Bird House: Fabrication Department 0.20 hr. at $16 per hr. Assembly Department 0.30 hr. at $12 per hr. Bird Feeder: Fabrication Department 0.40 hr. at $16 per hr. Assembly Department 0.35 hr. at $12 per hr. Estimated factory overhead costs for December: Indirect factory wages $75,000 Depreciation of plant and equipment 23,000 Power and light $6,000 Insurance and property tax 5,000 Estimated operating expenses for December: Sales salaries expense $70,000 Advertising expense 18,000 Office salaries expense 21,000 Depreciation expense—office equipment 600 Telephone expense—selling 550 Telephone expense—administrative 250 Travel expense—selling 4,000 Office supplies expense 200 Miscellaneous administrative expense 400 Estimated other income and expense for December: Interest revenue $200 Interest expense 122 Estimated tax rate: 30% Required: 1. Prepare a sales budget for December. Feathered Friends Inc. Sales Budget For the Month Ending December 31, 2016 Unit Sales Volume Unit Selling Price Total Sales Bird house Bird feeder Total revenue from sales 2. Prepare a production budget for December. Feathered Friends Inc. Production Budget For the Month Ending December 31, 2016 Units Bird House Bird Feeder Expected units to be sold Plus desired inventory, December 31, 2016 Total Less estimated inventory, December 1, 2016 Total units to be produced 3. Prepare a direct materials purchases budget for December. Feathered Friends Inc. Direct Materials Purchases Budget For the Month Ending December 31, 2016 Wood Plastic Total Required units for production: Bird house Bird feeder Plus desired units of inventory, December 31, 2016 Total Less estimated units of inventory, December 1, 2016 Total units to be purchased Unit price Total direct materials to be purchased 4. Prepare a direct labor cost budget for December. Feathered Friends Inc. Direct Labor Cost Budget For the Month Ending December 31, 2016 Fabrication Department Assembly Department Total Hours required for production: Bird house Bird feeder Total Hourly rate Total direct labor cost 5. Prepare a factory overhead cost budget for December. Feathered Friends Inc. Factory Overhead Cost Budget For the Month Ending December 31, 2016 Indirect factory wages Depreciation of plant and equipment Power and light Insurance and property tax Total 6. Prepare a cost of goods sold budget for December. Work in process at the beginning of December is estimated to be $29,000, and work in process at the end of December is estimated to be $35,400. Feathered Friends Inc. Cost of Goods Sold Budget For the Month Ending December 31, 2016 Direct materials: Cost of direct materials available for use Cost of direct materials placed in production Total manufacturing costs Total work in process during the period Cost of goods manufactured Cost of finished goods available for sale Cost of goods sold 7. Prepare a selling and administrative expenses budget for December. Feathered Friends Inc. Selling and Administrative Expenses Budget For the Month Ending December 31, 2016 Selling expenses: Sales salaries expense Advertising expense Telephone expense—selling Travel expense—selling Total selling expenses Administrative expenses: Office salaries expense Depreciation expense—office equipment Telephone expense—administrative Office supplies expense Miscellaneous administrative expense Total administrative expenses Total operating expenses 8. Prepare a budgeted income statement for December. Feathered Friends Inc. Budgeted Income Statement For the Month Ending December 31, 2016 Operating expenses: Total operating expenses Other income: Other expenses:

In: Accounting

Programming Assignment 5 Your work on the last project, the inventory ordering system, was so well...

Programming Assignment 5

Your work on the last project, the inventory ordering system, was so well received that your boss has asked you to write a new program for the firm. She mentions that she’s heard a lot about “Object Oriented Programming” and wants you to create a database of part’s suppliers that the company will use to source new inventory from. She mentions that there have been a lot of new entrants into the market and its important that you source the new widgets and sprockets at the best cost possible! From speaking with her you realize that you’ll need three new class definitions – a class that models a supplier, a class that represents a part, and class that will contain information about all these suppliers.

The parts class will need to contain the following information:

1. Part name

2. Part cost

The parts class will need to contain the following methods:

1. An init method that lets the user set the name and cost of the part

The supplier class will need to contain the following information:

1. The company name

2. A list of the parts the company supplies

The supplier class will need the following methods:

1. An init method to set the company name

2. A method that lets the user add a part to the list of parts a company supplies

3. A method that takes a part argument and returns the cost of that part.

4. A method that takes a part argument and returns a Boolean if the part is supplied by the company (True if it does, False if it does not).

The database class will need the following data:

1. A list of suppliers

The database class will need the following methods:

1. An init method to initialize the database

2. A method to add a supplier

3. A method to find the lowest cost for a part. The input will be a part name, and the output will be two values: the name of the supplier, and the cost. If the part is not sold by any suppliers, return False, False. Unlike in other programs – you do not need to write the code for user input, input validation, or output – you need only to write the classes! The company has supplied the program to load in the data and get the data from the classes, you need only to define the classes (and test with the supplied program of course)!

Sample Input/Output

Enter supplier name, or quit to exit: World Parts, Inc

Part info should be entered in the following format: name, price

Enter part info, or quit to exit: gizmo, 1.99

Enter part info, or quit to exit: sprocket, 3.12

Enter part info, or quit to exit: quit

Enter supplier name, or quit to exit: ABC Manufacturing

Part info should be entered in the following format: name, price

Enter part info, or quit to exit: sprocket, 3.09

Enter part info, or quit to exit: gizmo, 2.34

Enter part info, or quit to exit: dodad, 13.99

Enter part info, or quit to exit: quit

Enter supplier name, or quit to exit: quit

Supplier database complete!

Please enter in a part name or quit to exit: gizmo

Part gizmo is available for the best price at World Parts, Inc. Price: $1.99

Please enter in a part name or quit to exit: sprocket

Part sprocket is available for the best price at ABC Manufacturing. Price: $3.09

Please enter in a part name or quit to exit: dodad

Part dodad is available for the best price at ABC Manufacturing. Price: $13.99

Please enter in a part name or quit to exit: quit T

hank you for using the price database!

Additional requirements

1. You MUST use modules, you need to write your 3 classes in 3 separate Python files named database.py, part.py and supplier.py

2. Do NOT modify the supplied Python code – I will test your files with my own Python code – if you have to change the provided Python code to get your classes to work, you’ll lose points.

3. Submit only the 3 python files – part.py, supplier.py and database.py

4. Each Python file must have a program header!

Tips

1. The provided code does all the input/output for this program. You only need to write the code for the 3 classes.

2. Some of the methods for the 3 classes need to be of a specific format or the supplied program will not work – these are the init methods for Suppler and Database, and add_part, add_supplier, and find_part. Make sure you have those methods defined in your program and that their signature matches what the provided code expects.

3. Write the classes from simple to more complex – start with Part, then Supplier, then Database.

The following is a sample code

import database

import supplier

import part

supplier_database = database.Database()

while True:

    data = input("Enter supplier name, or quit to exit: ")

    if data == "quit":

        break

    s = supplier.Supplier(data)

    print("Part info should be entered in the following format: name, price")

    while True:

        part_info = input("Enter part info, or quit to exit: ")

        if part_info == "quit":

            print()

            break

        try:

            name, price = part_info.split(",")

            price = float(price)

        except:

            print("Error input - Part info should be entered in the following format: name, price - please try again")

            continue

        s.add_part(name, price)

    supplier_database.add_supplier(s)

print("\n\nSupplier database complete!\n")

while True:

    data = input("Please enter in a part name or quit to exit: ")

    if data == "quit":

        break

    

    supplier, price = supplier_database.find_part(data)

    if supplier == False:

        print("Error part does not exist in database")

    else:

        print(f"Part {data} is available for the best price at {supplier}. Price: ${price:.2f}")

print("\nThank you for using the price database!")

In: Computer Science

Assignment Implement Conway’s Game of Life. The Game of Life is a simple simulation that takes...

Assignment

Implement Conway’s Game of Life.

The Game of Life is a simple simulation that takes place in a grid of cells. Each cell can be either alive or dead, and it interacts with its neighbors (horizontally, vertically, or diagonally). In each iteration, a decision will be made to see if living cells stay alive, or if dead cells become alive. The algorithm is as follows:

If a cell is alive:

  • If it has less than two living neighbors, it dies due to loneliness.

  • If it has two or three living neighbors, it lives to the next generation

  • If it has more than three living neighbors, it dies due to overpopulation.

If a cell is dead:

  • and, if it has exactly three live neighbors, it becomes alive due to reproduction.

After each simulation round, your program must print the updated game board to screen.

Functional Requirements

  • MUST correctly play the Game of Life
  • You MUST use this life.h header file to find definitions
  • You MUST use this life.c file as a starting point for your implementation
  • You MUST assume a grid of 15x15
  • The grid size MUST be square
  • Your program MUST start with an initial grid in which cells (5,5) (5,6) (5,7) and (6,6) are alive and all others one are not
  • Your program MUST let the game run for 15 rounds
  • Your program MUST print the game board after each round
  • MUST load the initial state from text file
  • MUST load the number of rounds to play from text file
  • COULD load the grid size from the file

Nonfunctional Requirements

  • MUST compile without errors and warnings
  • You SHOULD implement the grid as a two-dimensional array.
  • The grid size MUST be defined as a preprocessor symbol
  • The number of rounds to run your program for MUST be defined as a preprocessor symbol

Hint

  • When doing a simulation run, define a second two-dimensional array. For each cell in the existing array, count the number of neighbors it has, and decide what its fate will be on the new board. After having done this for all cells, copy the value of your new board over the old one

life.h

/*
 * life.h
 *
 *  Created on: Sep 13, 2016
 *      Author: leune
 */

#ifndef LIFE_H_
#define LIFE_H_

#define XSIZE   15
#define YSIZE   15
#define DEFAULTROUNDS 15
#define ALIVE   1
#define DEAD    0

// initialize the board to all dead cells
void initBoard(int vBoard[][YSIZE]);

// play a round; updates the cells on the board
void playRound(int vBoard[][YSIZE]);

// print the board
void printBoard(int vBoard[][YSIZE]);

// determine the number of neighbors
int neighbors(int vBoard[][YSIZE], int x, int y);

/* determine if the given coordinates are within bounds
 * returns 0 if the cell is out of bounds; returns 1 if
 * the cell is in bounds
 */
int onBoard(int x, int y);

#endif /* LIFE_H_ */

life.c

/*
 * life.c
 *
 *  Created on: Sep 13, 2016
 *      Author: leune
 */
#include <stdio.h>
#include <unistd.h>
#include "life.h"

int main(int argc, char *argv[]) {
        int board[XSIZE][YSIZE];
        int rounds = DEFAULTROUNDS;

        initBoard(board);
        board[5][5] = ALIVE;
        board[5][6] = ALIVE;
        board[5][7] = ALIVE;
        board[6][6] = ALIVE;

        printf("Playing %d rounds.\n\n", rounds);
        for (int i=0; i<rounds; i++) {
                printf("Round: %d\n", i+1);
                printBoard(board);
                playRound(board);

                sleep(1);
        }

        return 0;
}


void initBoard(int vBoard[][YSIZE]) {
    /* write this function */
}

void playRound(int vBoard[][YSIZE]) {
        int tmpBoard[XSIZE][YSIZE];
        initBoard(tmpBoard);

        // perform the algorithm on vBoard, but update tmpBoard
        // with the new state
        
        /* write this fragment */

    // copy tmpBoard over vBoard
        for (int y=0; y < YSIZE; y++) {
                for (int x=0; x < XSIZE; x++) {
                        vBoard[x][y] = tmpBoard[x][y];
                }
        }
}

int onBoard(int x, int y) {
        if (x < 0 || x >= XSIZE)
                return 0;
        else
                if (y < 0 || y >= YSIZE) return 0;
        else
                return 1;
}

int neighbors(int vBoard[][YSIZE], int x, int y) {
        int n=0;

        int xp1 = x + 1;
        int xm1 = x - 1;
        int yp1 = y + 1;
        int ym1 = y - 1;

        if (onBoard(xm1, y) && vBoard[xm1][y] == ALIVE) n++;
        if (onBoard(xm1, yp1) && vBoard[xm1][yp1] == ALIVE) n++;
        if (onBoard(x, yp1) && vBoard[x][yp1] == ALIVE) n++;
        if (onBoard(xp1, yp1) && vBoard[xp1][yp1] == ALIVE) n++;
        if (onBoard(xp1, y) && vBoard[xp1][y] == ALIVE) n++;
        if (onBoard(xp1, ym1) && vBoard[xp1][ym1] == ALIVE) n++;
        if (onBoard(x, ym1) && vBoard[x][ym1] == ALIVE) n++;
        if (onBoard(xm1, ym1) && vBoard[xm1][ym1] == ALIVE) n++;

        return n;
}

void printBoard(int vBoard[XSIZE][YSIZE]) {
        /* write this fragment */
}

In: Computer Science

Assignment Implement Conway’s Game of Life IN C The Game of Life is a simple simulation...

Assignment

Implement Conway’s Game of Life IN C

The Game of Life is a simple simulation that takes place in a grid of cells. Each cell can be either alive or dead, and it interacts with its neighbors (horizontally, vertically, or diagonally). In each iteration, a decision will be made to see if living cells stay alive, or if dead cells become alive. The algorithm is as follows:

If a cell is alive:

  • If it has less than two living neighbors, it dies due to loneliness.

  • If it has two or three living neighbors, it lives to the next generation

  • If it has more than three living neighbors, it dies due to overpopulation.

If a cell is dead:

  • and, if it has exactly three live neighbors, it becomes alive due to reproduction.

After each simulation round, your program must print the updated game board to screen.

Functional Requirements

  • MUST correctly play the Game of Life
  • You MUST use this life.h header file to find definitions
  • You MUST use this life.c file as a starting point for your implementation
  • You MUST assume a grid of 15x15
  • The grid size MUST be square
  • Your program MUST start with an initial grid in which cells (5,5) (5,6) (5,7) and (6,6) are alive and all others one are not
  • Your program MUST let the game run for 15 rounds
  • Your program MUST print the game board after each round
  • MUST load the initial state from text file
  • MUST load the number of rounds to play from text file
  • COULD load the grid size from the file

Nonfunctional Requirements

  • MUST compile without errors and warnings
  • You SHOULD implement the grid as a two-dimensional array.
  • The grid size MUST be defined as a preprocessor symbol
  • The number of rounds to run your program for MUST be defined as a preprocessor symbol

Hint

  • When doing a simulation run, define a second two-dimensional array. For each cell in the existing array, count the number of neighbors it has, and decide what its fate will be on the new board. After having done this for all cells, copy the value of your new board over the old one

life.h

/*
 * life.h
 *
 *  Created on: Sep 13, 2016
 *      Author: leune
 */

#ifndef LIFE_H_
#define LIFE_H_

#define XSIZE   15
#define YSIZE   15
#define DEFAULTROUNDS 15
#define ALIVE   1
#define DEAD    0

// initialize the board to all dead cells
void initBoard(int vBoard[][YSIZE]);

// play a round; updates the cells on the board
void playRound(int vBoard[][YSIZE]);

// print the board
void printBoard(int vBoard[][YSIZE]);

// determine the number of neighbors
int neighbors(int vBoard[][YSIZE], int x, int y);

/* determine if the given coordinates are within bounds
 * returns 0 if the cell is out of bounds; returns 1 if
 * the cell is in bounds
 */
int onBoard(int x, int y);

#endif /* LIFE_H_ */

life.c

/*
 * life.c
 *
 *  Created on: Sep 13, 2016
 *      Author: leune
 */
#include <stdio.h>
#include <unistd.h>
#include "life.h"

int main(int argc, char *argv[]) {
        int board[XSIZE][YSIZE];
        int rounds = DEFAULTROUNDS;

        initBoard(board);
        board[5][5] = ALIVE;
        board[5][6] = ALIVE;
        board[5][7] = ALIVE;
        board[6][6] = ALIVE;

        printf("Playing %d rounds.\n\n", rounds);
        for (int i=0; i<rounds; i++) {
                printf("Round: %d\n", i+1);
                printBoard(board);
                playRound(board);

                sleep(1);
        }

        return 0;
}


void initBoard(int vBoard[][YSIZE]) {
    /* write this function */
}

void playRound(int vBoard[][YSIZE]) {
        int tmpBoard[XSIZE][YSIZE];
        initBoard(tmpBoard);

        // perform the algorithm on vBoard, but update tmpBoard
        // with the new state
        
        /* write this fragment */

    // copy tmpBoard over vBoard
        for (int y=0; y < YSIZE; y++) {
                for (int x=0; x < XSIZE; x++) {
                        vBoard[x][y] = tmpBoard[x][y];
                }
        }
}

int onBoard(int x, int y) {
        if (x < 0 || x >= XSIZE)
                return 0;
        else
                if (y < 0 || y >= YSIZE) return 0;
        else
                return 1;
}

int neighbors(int vBoard[][YSIZE], int x, int y) {
        int n=0;

        int xp1 = x + 1;
        int xm1 = x - 1;
        int yp1 = y + 1;
        int ym1 = y - 1;

        if (onBoard(xm1, y) && vBoard[xm1][y] == ALIVE) n++;
        if (onBoard(xm1, yp1) && vBoard[xm1][yp1] == ALIVE) n++;
        if (onBoard(x, yp1) && vBoard[x][yp1] == ALIVE) n++;
        if (onBoard(xp1, yp1) && vBoard[xp1][yp1] == ALIVE) n++;
        if (onBoard(xp1, y) && vBoard[xp1][y] == ALIVE) n++;
        if (onBoard(xp1, ym1) && vBoard[xp1][ym1] == ALIVE) n++;
        if (onBoard(x, ym1) && vBoard[x][ym1] == ALIVE) n++;
        if (onBoard(xm1, ym1) && vBoard[xm1][ym1] == ALIVE) n++;

        return n;
}

void printBoard(int vBoard[XSIZE][YSIZE]) {
        /* write this fragment */
}

In: Computer Science